Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upUnsafe Mutability Polymorphism #31
Comments
arielb1
added
the
K-Code-Example
label
Sep 25, 2016
This comment has been minimized.
This comment has been minimized.
Notice that this would be a violation of the types that are given; Could one argue that, when |
arielb1 commentedSep 25, 2016
One popular example of code where we are not certain about its UB status is mutability polymorphism:
Of course, the usage pattern is calling
get_mutand then mutating the value. However, with both the ACA and CA models, a reference derived from an&-reference has no write permissions, and writing through it causes self-aliasing-violation and UB.OTOH, having
getcallget_mutrather than vice-versa does not seem to create UB under both rules (because the reference is asserted only for reading), but without write-asserts to arguments we have the write-not-in-program issue.Still, having one of these cases UB and the other well-defined is ugly, and hard to tell to users.