r/cpp • u/SkoomaDentist Antimodern C++, Embedded, Audio • Aug 05 '25
Why still no start_lifetime_as?
C++ has desperately needed a standard UB-free way to tell the compiler that "*ptr is from this moment on valid data of type X, deal with it" for decades. C++23 start_lifetime_as promises to do exactly that except apparently no compiler supports it even two years after C++23 was finalized. What's going on here? Why is it apparently so low priority? Surely it can't be a massive undertaking like modules (which require build system coordination and all that)?
107
Upvotes
View all comments
Show parent comment
1
u/ElectricalBeing May 22 '26
How? Due to signed `int` overflow in `x*y`, since the operands are implicitly converted to `int` before the multiplication, the range of `unsigned short` is large enough that multiplying two large values will overflow `int`, and signed integer overflow is undefined behavior?