r/cpp • • Oct 24 '24

Why Safety Profiles Failed

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

347 comments sorted by

View all comments

Show parent comment

3

u/TheoreticalDumbass :illuminati: Oct 26 '24

if i pass aliasing references to safe code expecting them to not alias, is the UB at the callsite of safe code?

5

u/seanbaxter Oct 26 '24

Basically yes. Safe functions have defined behavior for all valid inputs. Mutable references that alias are not valid inputs. In a safe context, the compiler upholds that invariant. In an unsafe context it's up to the user not to break it with unsafe operations.