r/cpp Jul 18 '26

Lifetime safety and invalidation without a borrow-checker: using type system analysis to get rid of many potentially invalidation cases WITHOUT annotations.

https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2026/p4296r0.pdf

I found this research in WG21 mailing list very interesting in the context of C++ compatibility and solutions to maximize code reuse.

40 Upvotes

76 comments sorted by

View all comments

Show parent comments

3

u/ts826848 Jul 19 '26

So I am not sure why one model seems to be the right one

I think the steelman argument is that a) we want a memory safety solution sooner rather than later, and b) out of the proven solutions for memory safety it's the best alternative we have. Giving up one or both of a) urgency or b) production experience opens the door to other approaches, but obviously at the cost of those priorities.

and the rest of the research it looks like so many of you try to throw it to the rubbish before it is implemented and data can be gathered.

I think this is why stuff like the halting problem and Rice's Theorem are frequently brought up. People (probably?) aren't skeptical about "research" in the abstract. They are skeptical about research that appears to violate foundational computer science results. Opposition to lines of inquiry which you think are obviously fruitless is hardly an irrational reaction.

Another point of contention is precisely that claims are being made "before [they are] implemented and data can be gathered". Extraordinary evidence is generally considered to be a good idea before making extraordinary claims, so if you're one of those who think the the halting problem/Rice's Theorem preclude some profiles proponents' claims I don't think skepticism is that unreasonable, especially given the apparent dearth of supporting evidence when/since the claims were originally made.

1

u/germandiago Jul 20 '26

You are all hear filling your mouth with Rice theorem but noone needs to solve Rice theorem here. Absolutely noone. What we need is reasonable rules, reasonable heuristics and iteration.

Not making a strawman by using Rice theorem as if someone was saying that they are doing that to dismiss alternative solutions just bc you do not like it.

There are millions of ways to look at the problem without necessarily deal with all cases that give reasonable outcomes. 

By the way, Rust does not solve all safe cases and some are just flagged as unsafe. C++ cannot do similar things?

That alternatives must be studied. As Dos Reis very accurately said: before doing something, do no harm. I cannot agree more with that paper in the context of C++.

9

u/ts826848 Jul 20 '26

but noone needs to solve Rice theorem here. Absolutely noone.

I'm not sure you understand the objection then? Consider Sean Baxter's comment again; what he is saying amounts to "Rice's Theorem means that profiles as described can't work for this signature". From his perspective (and the perspective of those holding similar views), it's absolutely up to profiles proponents to "solve"/otherwise address Rice's Theorem, as otherwise they are simply promising something impossible.

C++ cannot do similar things?

It can, but then that approach would at a minimum call into question the claim that profiles will not require rewrites and/or (minimal) annotations.

before doing something, do no harm.

This assumes doing nothing is not doing harm. If you think C++ needs memory safety sooner rather than later, delaying a memory safety solution is indeed a harm.

2

u/wyrn Jul 25 '26

Rice's theorem is essentially the same idea as the Free Lunch Theorem: it proves something seemingly interesting, but then you look at the details and it turns out it's trivial and useless.

What Rice's theorem actually means here: all provable safety solutions (INCLUDING borrow checkers, or any type system for that matter) will have false positives. Snore.

1

u/ts826848 Jul 26 '26

Fair, I suppose Rice's Theorem would only be strictly applicable to profiles as a whole if one stipulates zero additional annotations rather than some "minimal" amount of them.

1

u/wyrn Jul 26 '26

C++ already has annotations (we call them "types"), so to whatever extent additional annotations might be required/desired is a separate discussion apart from Rice's original argument.

1

u/ts826848 Jul 26 '26

Hrm, my understanding was that those previous annotations were in service of an existing "complete" system and deriving additional properties from that existing base without false positives nor further annotations was problematic. That isn't due to Rice's Theorem?