logoalt Hacker News

guipsp • last Sunday at 9:43 PM • 5 replies • view on HN

Contracts are part of the memory safety story in c++


Replies

brigade • last Sunday at 10:03 PM

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.

➕ show 2 replies
leni536 • last Sunday at 10:12 PM

Contracts have nothing to do with memory safety.

➕ show 1 reply
112233 • yesterday at 6:24 AM

interesting. how would I use contracts to avoid returning (or passing to a function that can persist the value) a span or string_view that refers to local or temporary value? or a lambda that captures such value by reference?

locknitpicker • yesterday at 6:25 AM

> Contracts are part of the memory safety story in c++

Contracts are an optional debugging tool. They are literally designed to assert pre and post conditions. They are no better than the assert macro in asserting memory safety.

edflsafoiewq • last Sunday at 9:47 PM

How?

➕ show 1 reply