[Bug c++/79373] For loop optimization bug: condition ignored

2017-02-05 Thread steven.p.pigeon at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79373 --- Comment #10 from Steven Pigeon --- (In reply to Jonathan Wakely from comment #9) > (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 t

[Bug c++/79373] For loop optimization bug: condition ignored

2017-02-05 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79373 --- Comment #9 from Jonathan Wakely --- (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

[Bug c++/79373] For loop optimization bug: condition ignored

2017-02-05 Thread ebotcazou at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79373 Eric Botcazou changed: What|Removed |Added CC||ebotcazou at gcc dot gnu.org --- Comment

[Bug c++/79373] For loop optimization bug: condition ignored

2017-02-04 Thread steven.p.pigeon at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79373 --- Comment #7 from Steven Pigeon --- (In reply to Andrew Pinski from comment #6) > Once undefined behavior happens all bets are off of any behavior of the > program. > > In this case the function is in lined and the optimizers see i cannot > o

[Bug c++/79373] For loop optimization bug: condition ignored

2017-02-04 Thread pinskia at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79373 --- Comment #6 from Andrew Pinski --- Once undefined behavior happens all bets are off of any behavior of the program. In this case the function is in lined and the optimizers see i cannot overflow the multiply so it removes the loop check.

[Bug c++/79373] For loop optimization bug: condition ignored

2017-02-04 Thread steven.p.pigeon at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79373 --- Comment #5 from Steven Pigeon --- The problem is not the function that overflows. It's the loop that calls them that never stops. I don't see how that's "resolved": the overflow in the function should not affect the loop that calls it.

[Bug c++/79373] For loop optimization bug: condition ignored

2017-02-04 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79373 --- Comment #4 from Jonathan Wakely --- Use -fwrapv if you want predictable behaviour from integer overflow (both that and -fsanitize=undefined are mentioned at https://gcc.gnu.org/bugs)

[Bug c++/79373] For loop optimization bug: condition ignored

2017-02-04 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79373 Jonathan Wakely changed: What|Removed |Added Status|UNCONFIRMED |RESOLVED Resolution|---

[Bug c++/79373] For loop optimization bug: condition ignored

2017-02-03 Thread steven.p.pigeon at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79373 --- Comment #2 from Steven Pigeon --- (In reply to Andrew Pinski from comment #1) > I am suspecting this: > t*=65793; > > overflows. > > Can you try with -fsanitize=undefined ? The bug disappears with g++ -fsanitize=undefined -O3 -std

[Bug c++/79373] For loop optimization bug: condition ignored

2017-02-03 Thread pinskia at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79373 --- Comment #1 from Andrew Pinski --- I am suspecting this: t*=65793; overflows. Can you try with -fsanitize=undefined ?