The post proposes an idea about ClangIR based Safe C++ as an extension in clang. The proposed Safe C++ should be a pure subset of ISO C++ except few i

[RFC] A ClangIR based Safe C++

submited by
Style Pass
2024-11-24 10:00:02

The post proposes an idea about ClangIR based Safe C++ as an extension in clang. The proposed Safe C++ should be a pure subset of ISO C++ except few ignorable pragma and attributes. So that other compilers which don’t support the extension can compile the codes accepted by Safe C++. A demo implementation and examples are presented for readers to get a concrete feeling for the proposed language.

The post is inspired by the Safe C++ proposal. But the proposed language in that proposal is not C++. It brings more burdens to the designers, the implementors and the users.

So I am wondering if we can make a pure subset of C++ plus some ignorable pragma and attributes to make a Safe C++. The Safe C++ may reject valid C++ programs. But the valid Safe C++ program except the ignorable pragma and attributes must be a valid C++ programs too. In this way, the burdens on designing, implementation and users may be reduced significantly.

To avoid ambiguity, in the thread, I’ll call the proposal as Safe C++. And call the above proposal as Safe C++2. Beyond the thread, if you like, you can call the proposal as Clang Safe C++.

Leave a Comment