This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/81749] std::align: runtime error: negation of 8 cannot be represented in type 'size_t'
- From: "max at maxbruckner dot de" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 07 Aug 2017 15:12:09 +0000
- Subject: [Bug libstdc++/81749] std::align: runtime error: negation of 8 cannot be represented in type 'size_t'
- Auto-submitted: auto-generated
- References: <bug-81749-4@http.gcc.gnu.org/bugzilla/>
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.