http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49705

           Summary: -Wstrict-overflow should not diagnose unevaluated
                    expressions
           Product: gcc
           Version: 4.6.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassig...@gcc.gnu.org
        ReportedBy: egg...@gnu.org
              Host: x86_64-unknown-linux-gnu
            Target: x86_64-unknown-linux-gnu
             Build: x86_64-unknown-linux-gnu


I ran into this problem when compiling a test version of Emacs.
Here's a stripped-down version of the problem:

   int
   check_image_width (int width)
   {
     return (1 || width <= width + 2);
   }

When compiled with "gcc -c -Wstrict-overflow -O2 t.c" the diagnostic is:

   t.c:4:3: warning: assuming signed overflow does not occur when assuming that
(X + c) >= X is always true [-Wstrict-overflow]

This diagnostic is wrong, as the expression in question (width <=
width + 2) is unreachable.  In the original source code the
expression is unreachable because the code is carefully checking for
integer overflow.

GCC should not diagnose potential integer overflow in unreachable
expressions, as that is a common idiom in code that is working correctly.

Reply via email to