[Bug c/70619] Wrong warning with VLA, comma and sizeof
egallager at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Sun Jul 30 05:03:00 GMT 2017
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70619
Eric Gallager <egallager at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2017-07-30
CC| |egallager at gcc dot gnu.org
Ever confirmed|0 |1
--- Comment #1 from Eric Gallager <egallager at gcc dot gnu.org> ---
(In reply to Alexander Cherepanov from comment #0)
> 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.
Confirmed that the wording is confusing since there's no comma expression being
pointed to. The result of the sizeof is actually unused though, so ideally the
warning would just get reworded.
More information about the Gcc-bugs
mailing list