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
1
u/ts826848 Oct 28 '24
I think these are completely separate from aliasing? C# doesn't associate aliasing semantics with its version of
outIIRC, and I don't believe cpp2 associates aliasing semantics with those keywords....Like a new reference type?
So now you have "safe" and "unsafe" code? Which diverges from the actual profiles proposal and aligns more with Safe C++.
Again, the problem is what happens when the caller doesn't know that it needs to check. Consider using a compiler that isn't aware of profiles or one where the no-parameter-aliasing profile is disabled. How will the compiler know that aliasing checking is necessary?
Again, this seems like adding Safe C++-style safe/unsafe keywords/contexts. Which is something the actual profiles proposal explicitly wanted to avoid.
I think other potential issues are breaking ABI (e.g., so iterators/pointers/etc. can store references to their parent containers) and maybe forcing the existence of a runtime depending on the exact implementation.
And of course there's the elephant in the room - how would such aliasing checking work, especially if part of your program is compiled with profiles and part is not? One thing that comes to mind is that I don't believe there's an option to enable runtime checking for
restrict, though I don't know whether this is due to technical limitations or just a lack of demand.Again, the biggest problem here is that you're basically proposing an API break. Even worse, you're proposing an API break which has the potential to silently introduce broken code. The committee already strongly dislikes ABI breaks; an API break (especially one of this magnitude and with these potential consequences) would be even harder to justify. If you can't articulate why an API break is necessary and how programmers can avoid footguns when migrating then I don't think this idea has a chance of being adopted in its current form.
Individual implementations may find value in offering such a capability, but I suspect a proposal for a feature that does not work for closed-source libraries would be dead on arrival.