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 c/49705] New: -Wstrict-overflow should not diagnose unevaluated expressions


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: unassigned@gcc.gnu.org
        ReportedBy: eggert@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.


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