This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/70619] Wrong warning with VLA, comma and sizeof
- From: "egallager at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sun, 30 Jul 2017 05:03:23 +0000
- Subject: [Bug c/70619] Wrong warning with VLA, comma and sizeof
- Auto-submitted: auto-generated
- References: <bug-70619-4@http.gcc.gnu.org/bugzilla/>
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.