This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |INVALID

--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---

(In reply to Steven Pigeon from comment #2)
> (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=c++11 test-wave-stream.cpp 
> 
> Yes, it overflows for some values (and is undefined behavior?).

loop-bug/test-wave-stream.cpp:29:10: runtime error: signed integer overflow:
32641 * 65793 cannot be represented in type 'int'

> But it shouldn't affect the for-loop. At worse, the returned values should
> be random-looking and the unit test should fail with a message.

No, that's not what undefined behaviour means.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]