logoalt Hacker News

brigade • yesterday at 10:03 PM • 2 replies • view on HN

And that’s exactly why they’re so controversial. As adopted by the committee they do not do anything to provide memory safety.

The pushback from the final rejection got the committee to add the bare minimum that could help C++’s safety story.


Replies

btown • yesterday at 10:35 PM

To expand on this, my understanding is: the thing that held back approval (from the national bodies, not the committee itself) was that build configurations could turn off contract checks, which run at runtime, and still be standards-compliant. They wanted library authors to be able to write checks that will actually run, regardless of the build configuration of the person compiling!

So the “fix” was to let the author mark individual contracts as always enforced at runtime, with pre<enforced>. That, in turn, means a library’s key safety checks (bounds, null, etc.) can’t be silently dropped in a “loose” build configuration, which pushes things down a safer path.

Clunky IMO, but rather reasonable as a response to Rust!

It brings things closer to a world where: if you use these “safe” libraries, your program will stop rather than run unsafely, no matter how it was built.

➕ show 2 replies
mpyne • today at 12:01 AM

> The pushback from the final rejection got the committee to add the bare minimum that could help C++’s safety story.

What they added is no different in practice to what contracts already were before. If a compiler adds `-fno-contracts` then they will not be enforced, which was already the case.

But hey, if it helps C++ make it past the ISO process then it will have been a value-added change even though it's not actually any different.