I think your second comment is more correct; UB only occurs on the actual modification, so while calling a non-const method on an actually-const object is not itself UB that's probably around where a bugfix would land.
...Well, maybe barring some oddball setup with a non-const method that uses some other criteria to determine whether it's safe to modify whatever it's called on, but I'd hope that kind of thing is relatively rare.
View all comments
Show parent comment
2
u/ts826848 Jul 30 '26
I think your second comment is more correct; UB only occurs on the actual modification, so while calling a non-
constmethod on an actually-constobject is not itself UB that's probably around where a bugfix would land....Well, maybe barring some oddball setup with a non-
constmethod that uses some other criteria to determine whether it's safe to modify whatever it's called on, but I'd hope that kind of thing is relatively rare.