From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29366 invoked by alias); 19 Dec 2011 14:43:54 -0000 Received: (qmail 29357 invoked by uid 22791); 19 Dec 2011 14:43:53 -0000 X-SWARE-Spam-Status: No, hits=-2.9 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 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; Mon, 19 Dec 2011 14:43:40 +0000 From: "jakub at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/50012] [4.5/4.6/4.7 Regression] C++ front end misses -Wsign-compare warnings when extraneous parentheses are present Date: Mon, 19 Dec 2011 15:00:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Keywords: diagnostic X-Bugzilla-Severity: normal X-Bugzilla-Who: jakub at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 4.5.4 X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 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-12/txt/msg02124.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50012 --- Comment #5 from Jakub Jelinek 2011-12-19 14:43:05 UTC --- This has been introduced with http://gcc.gnu.org/ml/gcc-patches/2009-06/msg01402.html which has been written as a better way of: http://gcc.gnu.org/ml/gcc-patches/2009-06/msg01393.html Perhaps the older patch is a better way than this one, which, if I understand it right, is that ignoring of the promotion at the -Wsign-compare handling spot? Setting TREE_NO_WARNING, at least until we have a way to say which warnings we want to prohibit and which should be kept, is an ugly hack and shouldn't be taken lightly. While Ian's patch doesn't set TREE_NO_WARNING in this testcase, it just disables the warning if any of the operands is TREE_NO_WARNING and uses this bit for yet another purpose. The TREE_NO_WARNING bit in this case is set by finish_parenthesized_expr: 1504 if (EXPR_P (expr)) 1505 /* This inhibits warnings in c_common_truthvalue_conversion. */ 1506 TREE_NO_WARNING (expr) = 1; So, what was wrong with the first approach? And, perhaps for 4.8 we want to turn TREE_NO_WARNING bit into a bit that just tells us whether that tree in question is in some hash table (see e.g. DECL_HAS_VALUE_EXPR_P etc.) and that hash table would contain details what warnings are we supposed to ignore. This isn't the only problematic spot.