r/cpp
•
u/steveklabnik1
•
Oct 24 '24
•
1
Why Safety Profiles Failed
https://www.circle-lang.org/draft-profiles.html
180
Upvotes
View all comments
Show parent comment
6
u/rundevelopment Oct 26 '24
"No references alias" is one of the rules safety profiles uses. As explained in section 2.1 of the document, this rule is (1) overly restrictive and (2) not enough for safety.
Again, the point of this section was to show that C++ does not have enough information for useful aliasing analysis. You can impose rules and analyse based on those, but that doesn't mean that those rules will accomplish anything useful.
I also want to quickly point out that there is no "assume" when it comes to safety, there are only rules. If you say that references don't alias, then this rule has to be enforced on both caller and callee site. Anything else would be incorrect and therefore unsafe.
That's just Mutable Value Semantics, isn't it? Yes, MSV does work to guarantee memory safety but is quite restictive, because it demotes references to second-class citizens, which makes them a lot less powerful. E.g. custom pointer-like types like
std::vector<int>::iteratorare imposible with MSV, because you can't store references in structs. See the examples from section 2.1 again.I also have to point out that MSV only guarantees memory safety if it's MSV all the way down AFAIK, so it's not backwards compatible, requiring a break similar to Safe C++ because of the difference object model.