Comment by aw1621107
6 months ago
Pretty sure the std::abort() can't be optimized away if sz is mutable since it's legal for some_opaque_func() to cast away szRef's const and modify sz via that. sz itself needs to be const for the if statement to be removable as dead code.
https://cpp.godbolt.org/z/Pa3bMh9Ee shows that both GCC and Clang keep the abort when sz is not const. Add const and the abort goes away.
Yes, that is what I said - sorry if this wasn't clear
Looking back I think I might have misread your comment and thought you meant that the const on the reference was what mattered. Sorry about that!