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 middle-end/70455] New: spurious "assuming signed overflow does not occur when simplifying conditional to constant [-Wstrict-overflow]"


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

            Bug ID: 70455
           Summary: spurious "assuming signed overflow does not occur when
                    simplifying conditional to constant
                    [-Wstrict-overflow]"
           Product: gcc
           Version: 5.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: f.heckenbach@fh-soft.de
  Target Milestone: ---

Possibly a duplicate of 34515, but that one seems to have been ignored for
almost 10 years. At least, here's a shorter test case:

%cat test.c
int b = 0;

int main (void)
{
  int a = b >= 0 ? b : -b;
  if (a)
    a++;
  if (a)
    return 1;
  return 0;
}

%gcc -O2 -Wstrict-overflow test.c && ./a.out; echo $?
test.c: In function 'main':
test.c:10:6: warning: assuming signed overflow does not occur when simplifying
conditional to constant [-Wstrict-overflow]
   if (a)
         ^
0

It seems just the warning is off. If the condition itself were simplified to a
constant, that would be a serious bug (miscompilation), but it doesn't seem to.
If I change to "b = 1", it returns with exit code 1, as it should.

When I enabled -Wstrict-overflow on my code base, I got a number of such
warnings on conditions that (in my intention as the programmer) should not be
constant. If they were (due to overflow UB), I'd be worried, but as far as I
can reproduce so far, that's not the case. So for now, I have to conclude that
this warning is useless and have to turn it off again ... :(

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