https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70619
Bug ID: 70619
Summary: Wrong warning with VLA, comma and sizeof
Product: gcc
Version: 6.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: ch3root at openwall dot com
Target Milestone: ---
Compiling the program:
int main()
{
int a[1][(0, 1)];
int i = 0;
sizeof a[i++];
}
gives such warnings:
$ gcc -Wall example.c
example.c: In function ‘main’:
example.c:3:14: warning: left-hand operand of comma expression has no effect
[-Wunused-value]
int a[1][(0, 1)];
^
example.c:5:10: warning: right-hand operand of comma expression has no effect
[-Wunused-value]
sizeof a[i++];
~~~~~~~^~~~~~
The first one is fine but the second one is wrong and confusing.