This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/67661] Wrong warning when declare VLAs: operation on 'x' may be undefined [-Wsequence-point]
- From: "leechung at 126 dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 24 Sep 2015 01:08:01 +0000
- Subject: [Bug c/67661] Wrong warning when declare VLAs: operation on 'x' may be undefined [-Wsequence-point]
- Auto-submitted: auto-generated
- References: <bug-67661-4 at http dot gcc dot gnu dot org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67661
--- Comment #2 from leechung <leechung at 126 dot com> ---
(In reply to joseph@codesourcery.com from comment #1)
> You'll need to give a full testcase (complete compilable file and options
> used to compile it). What you gave isn't a compilable testcase; it gives
> "error: variably modified 'y' at file scope". Put inside a function, it
> gives "warning: unused variable 'y' [-Wunused-variable]", but does not
> give the warning you mention. And there's no variable 'b' in your example
> at all.
Sorry, I am less experience.
The following is the complete code:
#include <stdio.h>
int main (void)
{
int x = 0, y [++ x], z [++ x];
printf ("%d, %d, %d\n", sizeof x, sizeof y, sizeof z);
return 0;
}
and are compiled with option '-Wall'.for example:
gcc xx.c -Wall
then produce a warning 'operation on 'x' may be undefined [-Wsequence-point]'