3 ms·
While theoretically true, there are a whole bunch of undefined behaviors that are not caught in constexpr context in practice. In particular unsequenced operati
by leni536 4y ago
While theoretically true, there are a whole bunch of undefined behaviors that are not caught in constexpr context in practice. In particular unsequenced operations on the same object are typically not caught.
It's still super useful though, and more common language UBs are caught.
- hoosieree 4y agoThat's a compiler bug though, right? Doesn't the standard disallow UB in constexpr?
- leni536 4y agoIt is. Or if it is unfeasible to implement then it can be considered to be a defect in the standard. Consider that something like (++*ptr1) + (++*ptr2) may or may not be UB, depending where the pointer points to. The required additional bookkeeping might make compile time evaluation unpractically slow. Alternatively the sequencing could be always defined between any two subexpressions within constexpr context.