This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/47732] counter decremented to zero not detected when other counter overflows
- From: "J.K.Annot.at.Infor at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 15 Feb 2011 14:21:18 +0000
- Subject: [Bug c/47732] counter decremented to zero not detected when other counter overflows
- Auto-submitted: auto-generated
- References: <bug-47732-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47732
--- Comment #2 from Jan Koen Annot <J.K.Annot.at.Infor at gmail dot com> 2011-02-15 14:21:16 UTC ---
(In reply to comment #1)
> And overflow is undefined in C/C++ so you are invoking undefined behavior here.
Wow! This is an eye-opener for me! I am quite accustomed to assume two's
complement arithmetic with implicit wrap-around for signed integers.
After your remark I googled a bit and found several articles about undefined
behavior, e.g. John Regehr's "A Guide to Undefined Behavior in C and C++, Part
1".
Very instructive.