From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29599 invoked by alias); 7 Aug 2012 15:28:05 -0000 Received: (qmail 29591 invoked by uid 22791); 7 Aug 2012 15:28:05 -0000 X-SWARE-Spam-Status: No, hits=-3.6 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; Tue, 07 Aug 2012 15:27:46 +0000 From: "csaba_22 at yahoo dot co.uk" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/54194] New: GCC 4.8 gives misleading suggestion about arithmetic in operand of '|' Date: Tue, 07 Aug 2012 15:28:00 -0000 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: minor X-Bugzilla-Who: csaba_22 at yahoo dot co.uk 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 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: 2012-08/txt/msg00389.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54194 Bug #: 54194 Summary: GCC 4.8 gives misleading suggestion about arithmetic in operand of '|' Classification: Unclassified Product: gcc Version: 4.8.0 Status: UNCONFIRMED Severity: minor Priority: P3 Component: c++ AssignedTo: unassigned@gcc.gnu.org ReportedBy: csaba_22@yahoo.co.uk Using gcc version 4.8.0 20120806 (experimental) (GCC), Target: x86_64-unknown-linux-gnu to compile the following code: int main() { char in[4]={0}, out[6]; out[1] = in[1] & 0x0F | ((in[3] & 0x3C) << 2); } results in a misleading warning (misplaced caret): $ g++-48 -c -Wall -Werror w.cc w.cc: In function 'int main()': w.cc:4:45: error: suggest parentheses around arithmetic in operand of '|' [-Werror=parentheses] out[1] = in[1] & 0x0F | ((in[3] & 0x3C) << 2); ^ The problematic operand is the left operand of '|', but the caret appears to be pointing at the right operand. For example, clang version 3.2 (trunk 161319) gives $ clang++ -c -Wall -Werror w.cc w.cc:4:16: error: '&' within '|' [-Werror,-Wbitwise-op-parentheses] out[1] = in[1] & 0x0F | ((in[3] & 0x3C) << 2); ~~~~~~^~~~~~ ~ w.cc:4:16: note: place parentheses around the '&' expression to silence this warning out[1] = in[1] & 0x0F | ((in[3] & 0x3C) << 2); ^ ( )