This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libstdc++/81749] std::align: runtime error: negation of 8 cannot be represented in type 'size_t'


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81749

--- Comment #8 from Max Bruckner <max at maxbruckner dot de> ---
I understand how unsigned integers work and that they are defined by the
standard to have modular arithmetic. In this case I just didn't add 1 and 1
together I guess.

Nevertheless I disagree that there is no "overflow" or "underflow". It's a
question of how you define the two words, in a way, but being defined doesn't
make less of an underflow/overflow.

This is no bug, since std::align exhibits totally defined behavior, but I still
think that having a runtime check for unsigned overflow is quite useful,
because although it might not be undefined, it might still be unintended
behavior in many cases.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]