public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/50012] New: C++ front end misses -Wsign-compare warnings when extraneous parentheses are present
@ 2011-08-07 11:22 mikpe at it dot uu.se
  2011-08-07 19:52 ` [Bug c++/50012] " mikpe at it dot uu.se
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: mikpe at it dot uu.se @ 2011-08-07 11:22 UTC (permalink / raw)
  To: gcc-bugs

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

           Summary: C++ front end misses -Wsign-compare warnings when
                    extraneous parentheses are present
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: mikpe@it.uu.se


In this test case two similar functions compare an unsigned int with a signed
int, differing only in whether the unsigned sub-expression has an extra pair of
parentheses around it or not.  The C FE correctly issues a -Wsign-compare
diagnostic for both functions, but the C++ FE fails to do so for the function
with the extra parentheses.

> cat bug.c
int foo(unsigned int *a, int b)
{
    return (*a) <= b;
}

int bar(unsigned int *a, int b)
{
    return *a <= b;
}
> gcc/xgcc -Bgcc/ -O2 -Wsign-compare -S bug.c
bug.c: In function 'foo':
bug.c:3:17: warning: comparison between signed and unsigned integer expressions
[-Wsign-compare]
bug.c: In function 'bar':
bug.c:8:15: warning: comparison between signed and unsigned integer expressions
[-Wsign-compare]
> gcc/g++ -Bgcc/ -O2 -Wsign-compare -S /tmp/bug.c
/tmp/bug.c: In function 'int bar(unsigned int*, int)':
/tmp/bug.c:8:18: warning: comparison between signed and unsigned integer
expressions [-Wsign-compare]

This difference exists in 4.7-20110806, 4.6.1, and 4.5.3, but not in 4.4.6.

The test case is derived from ipa-inline-analysis.c, specifically Jan Hubicka's
recent change in r177484.  That change introduced a signed/unsigned comparison,
but due to this C++ FE bug and the recent "build stage2 etc with g++ by
default" change, the error went undetected.  That is, until people started
using --disable-build-poststage1-with-cxx to reduce bootstrap times, where it
ultimately breaks bootstrap, see PR50005.


^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2012-11-13 11:24 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-07 11:22 [Bug c++/50012] New: C++ front end misses -Wsign-compare warnings when extraneous parentheses are present mikpe at it dot uu.se
2011-08-07 19:52 ` [Bug c++/50012] " mikpe at it dot uu.se
2011-08-08 10:09 ` [Bug c++/50012] [4.5/4.6/4.7 Regression] " rguenth at gcc dot gnu.org
2011-08-14 12:43 ` mikpe at it dot uu.se
2011-08-19  7:34 ` jakub at gcc dot gnu.org
2011-10-10 12:19 ` rguenth at gcc dot gnu.org
2011-12-19 15:00 ` jakub at gcc dot gnu.org
2012-01-05 17:43 ` jakub at gcc dot gnu.org
2012-01-07  1:32 ` ian at airs dot com
2012-01-14  0:26 ` ian at gcc dot gnu.org
2012-01-14  0:27 ` [Bug c++/50012] [4.5/4.6 " ian at airs dot com
2012-07-02 12:07 ` rguenth at gcc dot gnu.org
2012-11-13 11:24 ` [Bug c++/50012] [4.6 " paolo.carlini at oracle dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).