--- Comment #8 from rguenth at gcc dot gnu dot org 2008-08-09 21:07 ---
You can use -fwrapv.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37067
--- Comment #7 from brian at dessent dot net 2008-08-09 21:00 ---
Subject: Re: gcc creating wrong code with -O2
Just make it unsigned since unsigned overflow is always defined.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37067
--- Comment #6 from stefan dot bruens at rwth-aachen dot de 2008-08-09
20:56 ---
So is there any possibility to flag a variable to be expected to overflow and
"wrap around"? I think there is a lot of code in the wild assuming the loop to
run 10 times and d_phase to overflow all the
--- Comment #5 from pinskia at gcc dot gnu dot org 2008-08-09 20:46 ---
>The loop should run 10 times, as i does not overflow.
i does not overflow but d_phase does ...
2046 7ff0
2047 8000
That is an overflow.
So is:
4094 fff0
4095 0
--
http://gcc.gnu.org/bugzilla/
--- Comment #4 from rguenth at gcc dot gnu dot org 2008-08-09 20:43 ---
As I said - it works for me (i686, gcc (Debian 4.3.1-8) 4.3.1). Still the
overflow invokes undefined behavior and thus _can_ affect the loop.
--
rguenth at gcc dot gnu dot org changed:
What|Remov
--- Comment #3 from pinskia at gcc dot gnu dot org 2008-08-09 20:42 ---
>The loop should run 10 times, as i does not overflow.
i does not overflow but d_phase_inc does ...
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37067
--- Comment #2 from stefan dot bruens at rwth-aachen dot de 2008-08-09
20:37 ---
The expected output is quite clear - 69f0 6a00 - but output is 69f0
0.
The loop should run 10 times, as i does not overflow.
d_phase does overflow after 2048 steps, but this should not influ
--- Comment #1 from rguenth at gcc dot gnu dot org 2008-08-09 18:01 ---
This works for me as far as I can see (you didn't specify the expected
output, and certainly if the loop doesn't run as often as you want you
may print uninitialized memory). Anyway, if it doesn't work then it is
be