r/cpp • • Oct 24 '24

Why Safety Profiles Failed

https://www.circle-lang.org/draft-profiles.html
184 Upvotes

347 comments sorted by

View all comments

Show parent comment

1

u/germandiago Oct 26 '24

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.

What do you mean here by "useful". That is a very difficult thing to define in the gray areas IMHO and why the topic is so contentious.

E.g. custom pointer-like types like std::vector<int>::iterator are imposible with MSV, because you can't store references in structs. See the examples from section 2.1 again.

Yes, I am aware of this. I just think we are not at the end of the road yet :)

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.

Again, and maybe it is magic (not possible?) but then I would restrict current syntax to change semantics in already-working code to save for an analysis. I think it is a good idea (in any proposal) to ban problematic constructs and go with what is remaining but I do know you consider that this subset would not be useful enough. However, by useful I am not sure what the definition of that is and I am pretty sure it is not simple to define and where all the discussion could end up focusing (which is the right place, probably).

3

u/rundevelopment Oct 26 '24

What do you mean here by "useful".

How about a solution for memory safety that actually works?

I mean, the promise of safety profiles was that they can "detect all lifetime safety defects in existing C++ code." But they cannot as demonstrated in this document.

After memory safety is guaranteed, we can talk about the trade offs different solutions have, but safety profiles aren't even there yet.

I just think we are not at the end of the road yet :)

Then please write a paper or article explaining your alternative solution in detail. I have no interest in discussing a magical non-existent solution to a real problem.

2

u/germandiago Oct 26 '24 edited Oct 26 '24

I am aware you know more about the topic than me.  However, you can detect aliasing at runtime by injection for old code on recompile and add in/out/inout parameters to functions that do not alias as a new feature restricted to only function parameters that does not go viral. 

Would that not be possible? Just asking about possible, not about optimal runtime performance.

Old code -> runtime injection and compatible.   New code -> static guarantees, not viral type system.

  My goal here would be to achieve something as close to compatible code as possible where old code can be used safely and analyzed.