This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/60442] New: No -Wparentheses warning for "if (a += b)"
- From: "chengniansun at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 06 Mar 2014 09:12:39 +0000
- Subject: [Bug c/60442] New: No -Wparentheses warning for "if (a += b)"
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60442
Bug ID: 60442
Summary: No -Wparentheses warning for "if (a += b)"
Product: gcc
Version: 4.9.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: chengniansun at gmail dot com
The gcc trunk emits -Wparentheses warnings for "if(a = b)" and "if(a = a + b)",
but not "if(a += b)"
$: cat s.c
int b;
int f(int a) {
if (a = b)
return 0;
else if (a = a + b)
return 3;
else if (a += b) /* <- no warning here*/
return 2;
else
return 1;
}
$: gcc-trunk -Wparentheses -c s.c
s.c: In function âfâ:
s.c:3:3: warning: suggest parentheses around assignment used as truth value
[-Wparentheses]
if (a = b)
^
s.c:5:3: warning: suggest parentheses around assignment used as truth value
[-Wparentheses]
else if (a = a + b)
^
$: