This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/80202] Spurious warning "array subscript is below array bounds" with if-statement and char to unsigned int conversion
- 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, 27 Mar 2017 08:47:02 +0000
- Subject: [Bug c++/80202] Spurious warning "array subscript is below array bounds" with if-statement and char to unsigned int conversion
- Auto-submitted: auto-generated
- References: <bug-80202-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80202
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2017-03-27
Ever confirmed|0 |1
--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
Confirmed for GCC 6, seems to be fixed on trunk. It's a missed optimization in
VRP:
<bb 2>:
_3 = (int) reg_2(D);
if (_3 <= 0)
goto <bb 3>;
else
goto <bb 6>;
<bb 3>:
_9 = ASSERT_EXPR <_3, _3 <= 0>;
switch (reg_2(D)) <default: <L4>, case 1 ... 2: <L3>>
we fail to place an assertion for reg_2(D).
OTOH for trunk we simplify the test to if (reg == 0) there and thus
simplify the situation upfront.