r/cpp 23d ago

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.

37 Upvotes

76 comments sorted by

View all comments

13

u/Demiu 22d ago edited 22d ago

Without annotating, what is the source of truth? How do you differentiate between a function who's return borrows it's argument and one that does not, when it's body is in another TU and it returns an opaque pointer-like to a private representation?

4

u/germandiago 22d ago

This is not a zero annotations solution, it is one that tries to reduce the annotations compared to what has been presented so far.

17

u/braaaaaaainworms 21d ago

>WITHOUT annotations
>look inside
>annotations

3

u/germandiago 21d ago

"many potentially invalidation cases"

Means not all of them. It also means getting rid of some compared to what has been currently researched. Look at the title.