[Bug c/67661] New: Wrong warning when declare VLAs: operation on 'b' may be undefined [-Wsequence-point]
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67661 Bug ID: 67661 Summary: Wrong warning when declare VLAs: operation on 'b' may be undefined [-Wsequence-point] Product: gcc Version: 5.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: leechung at 126 dot com Target Milestone: --- The following code produces a warning: operation on 'b' may be undefined.[-Wsequence-point] int x = 0, y [++ x], z [++ x]; But N1570 6.8 says: A block allows a set of declarations and statements to be grouped into one syntactic unit. The initializers of objects that have automatic storage duration, and the variable length array declarators of ordinary identifiers with block scope, are evaluated and the values are stored in the objects (including storing an indeterminate value in objects without an initializer) each time the declaration is reached in the order of execution, as if it were a statement, and within each declaration in the order that declarators appear. and 6.7.6 says: A full declarator is a declarator that is not part of another declarator. The end of a full declarator is a sequence point.
[Bug c/67661] Wrong warning when declare VLAs: operation on 'x' may be undefined [-Wsequence-point]
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67661 --- Comment #2 from leechung --- (In reply to jos...@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 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]'