https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114554

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Plus I get the following warnings at -O2:
In function 'wyrand',
    inlined from 'main' at <source>:84:5:
<source>:76:7: warning: iteration 2 invokes undefined behavior
[-Waggressive-loop-optimizations]
   76 |   *p1 += 3257665815644502181;
      |       ^~
<source>: In function 'main':
<source>:83:12: note: within this loop
   83 |   for (; i < 10; i++) {
      |          ~~^~~~
ASM generation compiler returned: 0
In function 'wyrand',
    inlined from 'main' at <source>:84:5:
<source>:76:7: warning: iteration 2 invokes undefined behavior
[-Waggressive-loop-optimizations]
   76 |   *p1 += 3257665815644502181;
      |       ^~
<source>: In function 'main':
<source>:83:12: note: within this loop
   83 |   for (; i < 10; i++) {
      |          ~~^~~~


With -fwrapv, the code "works" but that is because signed integer overflow has
changed from undefined behavior to being defined as wrapping.

Reply via email to