This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/79373] For loop optimization bug: condition ignored
- From: "redi at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 06 Feb 2017 01:23:24 +0000
- Subject: [Bug c++/79373] For loop optimization bug: condition ignored
- Auto-submitted: auto-generated
- References: <bug-79373-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79373
--- Comment #9 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Steven Pigeon from comment #7)
> I do understand that this is what happens (the code is fixed by promoting
> int32_t t=x to int64_t t=x) but the undefined behavior affects a variable
> (and its associated comparison) that should not be affected by it.
The C++ standards defines undefined behavior as "behavior for which this
International Standard imposes no requirements". No requirements. Not "doesn't
affect things that you think shouldn't be affected". All bets are off.
There is no requirement for a compiler to do something you find unsurprising,
or to limit the scope of the bug to parts of the code you expect to misbehave.