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 tree-optimization/84084] [Regression 7/8][-O2] Early VRP pass wrongly removes "ret" exit basic block causing wrong behavior


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

Richard Biener <rguenth at gcc dot gnu.org> changed:

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

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
You are invoking undefined behavior as you correctly noted.  So the compiler is
free to optimize the code by removing the exit test -- i < 2 has to be always
true for a[i] to be not undefined.

I suggest to write (i < 2 && (val = arr[i], true)) instead.

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