September 12th, 2024

Safe C++: Language Extensions for Memory Safety

The C++ Alliance has partnered with Sean Baxter to develop Safe C++ Extensions, enhancing memory safety and introducing a Safe Standard Library, while inviting community feedback for refinement.

Read original articleLink Icon
Safe C++: Language Extensions for Memory Safety

The C++ Alliance has announced a partnership with engineer Sean Baxter to develop the Safe C++ Extensions proposal, which aims to enhance memory safety in the C++ programming language. This initiative responds to the growing demand for secure and reliable software, addressing common memory-related errors that developers face. The Safe C++ Extensions will introduce new features while maintaining the language's performance and flexibility. A significant aspect of this proposal is the Safe Standard Library, which will offer memory-safe implementations of essential data structures and algorithms, ensuring that safety is prioritized in new code development. The C++ Alliance and Baxter are inviting feedback from developers, researchers, and stakeholders to refine the proposal and ensure it meets the needs of the C++ community. Interested parties can access the latest draft and participate in discussions through the official Safe C++ website and the C++ Language Slack Workspace.

- The C++ Alliance partners with Sean Baxter to enhance memory safety in C++.

- The Safe C++ Extensions aim to prevent common memory-related errors.

- A new Safe Standard Library will provide memory-safe data structures and algorithms.

- Feedback from the community is sought to refine the proposal.

- The initiative emphasizes the importance of secure coding practices in software development.

Link Icon 7 comments
By @pornel - 7 months
This is based on circle, which looks very Rust-like, and is probably the most sound design of all the contenders for the next C++. It has an actual safe-only mode, with strict aliasing, no uninit memory, and loans tracked via control-flow graph.

Many other "safe" C++ extensions just add basic bounds checking, and end at "we have smart pointers, what else do you want!?!??!?"

By @lbhdc - 7 months
This looks really interesting! It does look very rust like.

    auto get_x/(a, b)(const int^/a x, const int^/b y) -> const int^/a {
      return x;
    }
I like the new `choice` type. It looks like a c++ flavored rust enum.

    template<class T+, class E+>
    choice expected {
      [[safety::unwrap]] ok(T),
      err(E);
    
      T unwrap(self) noexcept safe {
        return match(self) -> T {
          .ok(t)  => rel t;
          .err(e) => panic("{} is err".format(expected~string));
        };
      }
    };
By @musicale - 7 months
And it only took 40 years (and the development of Java, JavaScript, Go, Rust, even smart pointers in C++ itself, etc.) for C++ implementors to realize it is a good idea!

Perhaps LLVM supporting improved memory safety (e.g. for Swift) is helpful as well.

By @footguhn - 7 months
Add rust JIT to C++. No hope to keep up with all that is going to be and has been added to C++ in last decade
By @ladyanita22 - 7 months
What are the chances of this proposal making the cut?