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

--- Comment #9 from Franz Sirl <sirl at gcc dot gnu.org> ---
With r244892 and -O2 -Wformat-truncation=2 I nearly get the warnings I expect. 

What remains is case 3, but this seems to be a small deficiency in VRP. For the
term I used ((val < 0) ? -(val % 100) : (val % 100)), it seems VRP cannot
deduce that both branches of the IF finally result in [0, 99]. On the other
hand, a "normal" abs()-like macro would result in (((val % 100) < 0) ? -(val %
100) : (val % 100)), which some other pass turns into an ABS_EXPR which is
handled fine by VRP and accordingly the warning goes away too.

It seems a part of 78703 is still missing, because there are still warnings at
-O0?

To make my point about the warnings at -O0 more clear, I believe a false
positive at -O0 even though the argument was already properly (!) range limited
at the spot (which I believe would be a common way for programmers to kill the
warning) is really not helpful. So with a mini-VRP at -O0 for function
arguments the warning could be acceptable at -O0. But in its current state I
believe the warning should only be turned on automatically when VRP is active.

Reply via email to