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: unassig...@gcc.gnu.org ReportedBy: csaba...@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); ^ ( )