This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/84084] [Regression 7/8][-O2] Early VRP pass wrongly removes "ret" exit basic block causing wrong behavior
- From: "rguenth at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 29 Jan 2018 09:28:06 +0000
- Subject: [Bug tree-optimization/84084] [Regression 7/8][-O2] Early VRP pass wrongly removes "ret" exit basic block causing wrong behavior
- Auto-submitted: auto-generated
- References: <bug-84084-4@http.gcc.gnu.org/bugzilla/>
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.