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 27 '24
I think this is trying to address a different question than what I was talking about. I'm talking about cases where you don't have end-to-end control of the toolchain - in other words, precisely those scenarios where your assumption is invalid. For example, cases where you are shipping a DLL to customers, in which case the analysis would look more like:
I'd argue that this kind of situations are extremely common - common enough that not supporting them is an automatic dealbreaker. For example, consider the MSVC runtime DLLs - if your no-aliasing-parameters profile requires all consuming code to use it, it means that Microsoft cannot use that profile for the MSVC runtime DLLs unless every single program using the MSVC DLLs also uses that profile. Think about how long companies can take to adopt new features - it may take decades until Microsoft can enable your no-aliasing-parameters profile, if that even happens at all!
You seem to have new stuff here that allows the compiler to determine that a profile is being used. This seems to be a change from earlier comments, where you did not want to require code changes to use safety features. I think this also diverges from the actual profiles proposal, which did not want to add anything along the lines of "safe" or "unsafe" annotations.
There's a somewhat more subtle issue as well, which I alluded to above - what happens if your dependency is provided by someone else who is using your no-aliasing-parameters profile but your compiler doesn't (yet) support that profile? Under the existing rules for annotations the compiler can legally ignore the profiles annotation and because the function signature looks the same the code will successfully compile. You may get a warning, but it's just a warning - it can be ignored, buried under other warnings, accidentally missed, dismissed as harmless, etc.
Again, this is an argument for new syntax - sure, you need to update old code, but you'd need to look at old code anyways to account for the API break.
As I told you before, read Sean's comment and the surrounding comments. I've reproduced a bit here and emphasized what seems to be a particularly relevant part:
Sean seems to be stating that Safe C++ is not all-or-nothing. You can enable some safety features selectively within specific scopes, so you can enable Safe C++ piecemeal within your codebase.
As I said above, this diverges from the actual profiles proposal which does not want to split the world into "safe"/"unsafe" and is more similar to the
safe/unsafekeywords Safe C++ uses.