From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18294 invoked by alias); 7 Aug 2011 11:22:23 -0000 Received: (qmail 18285 invoked by uid 22791); 7 Aug 2011 11:22:23 -0000 X-SWARE-Spam-Status: No, hits=-2.8 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00,TW_CX X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 07 Aug 2011 11:22:09 +0000 From: "mikpe at it dot uu.se" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/50012] New: C++ front end misses -Wsign-compare warnings when extraneous parentheses are present X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: mikpe at it dot uu.se X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Date: Sun, 07 Aug 2011 11:22:00 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2011-08/txt/msg00776.txt.bz2 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.