This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/29970] mixing ({...}) with VLA leads to massive breakage
- From: "msebor at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 24 Feb 2017 04:05:18 +0000
- Subject: [Bug c/29970] mixing ({...}) with VLA leads to massive breakage
- Auto-submitted: auto-generated
- References: <bug-29970-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=29970
Martin Sebor <msebor at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |ice-on-valid-code,
| |wrong-code
Status|UNCONFIRMED |NEW
Last reconfirmed| |2017-02-24
CC| |msebor at gcc dot gnu.org
Ever confirmed|0 |1
Known to fail| |4.3.2, 4.6.0, 5.3.0, 6.3.0,
| |7.0
--- Comment #4 from Martin Sebor <msebor at gcc dot gnu.org> ---
Confirmed with today's top of trunk (7.0). It might be worthwhile to break up
the test cases into individual bugs.
$ (set -x && cat t.c && for n in 1 2 3 4 5; do gcc -DTEST=$n -O2 -S -Wall
-Wextra -Wpedantic -fdump-tree-optimized=/dev/stdout t.c; done)
+ cat t.c
#if TEST == 1
int foo(int n) // should not ICE
{
return ({struct {int x[n];} x; x.x[12] = 1; x;}).x[12];
}
#elif TEST == 2
int foo(void) // should not ICE
{
return sizeof({int n = 20; struct {int x[n];} x; x.x[12] = 1; x;});
}
#elif TEST == 3
int foo(void) // should not return 0
{
int n = 0;
return sizeof({n = 10; struct {int x[n];} x; x;});
}
#elif TEST == 4
int foo(void) // should not ICE
{
return (*({
int n = 20;
char (*x)[n][n] = __builtin_malloc(n * n);
(*x)[12][1] = 1;
x;
}))[12][1];
}
#elif TEST == 5
int foo(void) // should return 1, returns 0
{
int n = 0;
return (*({
n = 20;
char (*x)[n][n] = __builtin_malloc(n * n);
(*x)[12][1] = 1;
(*x)[0][1] = 0;
x;
}))[12][1];
}
#endif
+ for n in 1 2 3 4 5
+ gcc -DTEST=1 -O2 -S -Wall -Wextra -Wpedantic
-fdump-tree-optimized=/dev/stdout t.c
t.c: In function ‘foo’:
t.c:4:30: warning: a member of a structure or union cannot have a variably
modified type [-Wpedantic]
return ({struct {int x[n];} x; x.x[12] = 1; x;}).x[12];
^
t.c:4:16: warning: ISO C forbids braced-groups within expressions [-Wpedantic]
return ({struct {int x[n];} x; x.x[12] = 1; x;}).x[12];
^
;; Function foo (foo, funcdef_no=0, decl_uid=1795, cgraph_uid=0,
symbol_order=0)
foo (int n)
{
struct
{
int x[0:D.1807];
} * x.1;
struct
{
int x[0:D.1807];
} * D.1814;
sizetype _1;
sizetype _2;
int _16;
<bb 2> [100.00%]:
_1 = (sizetype) n_3(D);
_2 = _1 * 4;
_8 = __builtin_alloca_with_align (_2, 32);
x.1_12 = __builtin_alloca_with_align (_2, 32);
x.1_12->x[12] = 1;
__builtin_memcpy (_8, x.1_12, _2);
_16 = _8->x[12];
return _16;
}
+ for n in 1 2 3 4 5
+ gcc -DTEST=2 -O2 -S -Wall -Wextra -Wpedantic
-fdump-tree-optimized=/dev/stdout t.c
t.c: In function ‘foo’:
t.c:9:48: warning: a member of a structure or union cannot have a variably
modified type [-Wpedantic]
return sizeof({int n = 20; struct {int x[n];} x; x.x[12] = 1; x;});
^
t.c:9:22: warning: ISO C forbids braced-groups within expressions [-Wpedantic]
return sizeof({int n = 20; struct {int x[n];} x; x.x[12] = 1; x;});
^
t.c:9:22: internal compiler error: in gimplify_var_or_parm_decl, at
gimplify.c:2582
return sizeof({int n = 20; struct {int x[n];} x; x.x[12] = 1; x;});
~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
0xb93ec7 gimplify_var_or_parm_decl
/ssd/src/gcc/git-svn/gcc/gimplify.c:2582
0xbba91b gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
/ssd/src/gcc/git-svn/gcc/gimplify.c:11635
0xb8d9ba internal_get_tmp_var
/ssd/src/gcc/git-svn/gcc/gimplify.c:567
0xb8dd96 get_initialized_tmp_var(tree_node*, gimple**, gimple**, bool)
/ssd/src/gcc/git-svn/gcc/gimplify.c:620
0xb9f95c gimplify_save_expr
/ssd/src/gcc/git-svn/gcc/gimplify.c:5762
0xbb9e44 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
/ssd/src/gcc/git-svn/gcc/gimplify.c:11490
0xbb934d gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
/ssd/src/gcc/git-svn/gcc/gimplify.c:11294
0xbbb651 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
/ssd/src/gcc/git-svn/gcc/gimplify.c:11921
0xbb934d gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
/ssd/src/gcc/git-svn/gcc/gimplify.c:11294
0xb9e1dd gimplify_modify_expr
/ssd/src/gcc/git-svn/gcc/gimplify.c:5457
0xbb8c6d gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
/ssd/src/gcc/git-svn/gcc/gimplify.c:11192
0xba23ca gimplify_stmt(tree_node**, gimple**)
/ssd/src/gcc/git-svn/gcc/gimplify.c:6478
0xb8d545 gimplify_and_add(tree_node*, gimple**)
/ssd/src/gcc/git-svn/gcc/gimplify.c:435
0xb907ab gimplify_return_expr
/ssd/src/gcc/git-svn/gcc/gimplify.c:1521
0xbb9c95 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
/ssd/src/gcc/git-svn/gcc/gimplify.c:11451
0xba23ca gimplify_stmt(tree_node**, gimple**)
/ssd/src/gcc/git-svn/gcc/gimplify.c:6478
0xb8fbd2 gimplify_bind_expr
/ssd/src/gcc/git-svn/gcc/gimplify.c:1290
0xbb9938 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
/ssd/src/gcc/git-svn/gcc/gimplify.c:11391
0xba23ca gimplify_stmt(tree_node**, gimple**)
/ssd/src/gcc/git-svn/gcc/gimplify.c:6478
0xbbcf89 gimplify_body(tree_node*, bool)
/ssd/src/gcc/git-svn/gcc/gimplify.c:12388
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
+ for n in 1 2 3 4 5
+ gcc -DTEST=3 -O2 -S -Wall -Wextra -Wpedantic
-fdump-tree-optimized=/dev/stdout t.c
t.c: In function ‘foo’:
t.c:15:44: warning: a member of a structure or union cannot have a variably
modified type [-Wpedantic]
return sizeof({n = 10; struct {int x[n];} x; x;});
^
t.c:15:22: warning: ISO C forbids braced-groups within expressions [-Wpedantic]
return sizeof({n = 10; struct {int x[n];} x; x;});
^
;; Function foo (foo, funcdef_no=0, decl_uid=1795, cgraph_uid=0,
symbol_order=0)
foo ()
{
<bb 2> [100.00%]:
return 0;
}
+ for n in 1 2 3 4 5
+ gcc -DTEST=4 -O2 -S -Wall -Wextra -Wpedantic
-fdump-tree-optimized=/dev/stdout t.c
t.c: In function ‘foo’:
t.c:20:18: warning: ISO C forbids braced-groups within expressions [-Wpedantic]
return (*({
^
t.c:25:24: internal compiler error: in gimplify_var_or_parm_decl, at
gimplify.c:2582
return (*({
~~~~
int n = 20;
~~~~~~~~~~~
char (*x)[n][n] = __builtin_malloc(n * n);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
(*x)[12][1] = 1;
~~~~~~~~~~~~~~~~
x;
~~
}))[12][1];
~~~~~~~^~~
0xb93ec7 gimplify_var_or_parm_decl
/ssd/src/gcc/git-svn/gcc/gimplify.c:2582
0xbba91b gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
/ssd/src/gcc/git-svn/gcc/gimplify.c:11635
0xb8d9ba internal_get_tmp_var
/ssd/src/gcc/git-svn/gcc/gimplify.c:567
0xb8dd96 get_initialized_tmp_var(tree_node*, gimple**, gimple**, bool)
/ssd/src/gcc/git-svn/gcc/gimplify.c:620
0xb9f95c gimplify_save_expr
/ssd/src/gcc/git-svn/gcc/gimplify.c:5762
0xbb9e44 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
/ssd/src/gcc/git-svn/gcc/gimplify.c:11490
0xbb934d gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
/ssd/src/gcc/git-svn/gcc/gimplify.c:11294
0xb9484f gimplify_compound_lval
/ssd/src/gcc/git-svn/gcc/gimplify.c:2799
0xbb8ad1 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
/ssd/src/gcc/git-svn/gcc/gimplify.c:11144
0xbb934d gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
/ssd/src/gcc/git-svn/gcc/gimplify.c:11294
0xb9e1dd gimplify_modify_expr
/ssd/src/gcc/git-svn/gcc/gimplify.c:5457
0xbb8c6d gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
/ssd/src/gcc/git-svn/gcc/gimplify.c:11192
0xba23ca gimplify_stmt(tree_node**, gimple**)
/ssd/src/gcc/git-svn/gcc/gimplify.c:6478
0xb8d545 gimplify_and_add(tree_node*, gimple**)
/ssd/src/gcc/git-svn/gcc/gimplify.c:435
0xb907ab gimplify_return_expr
/ssd/src/gcc/git-svn/gcc/gimplify.c:1521
0xbb9c95 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
/ssd/src/gcc/git-svn/gcc/gimplify.c:11451
0xba23ca gimplify_stmt(tree_node**, gimple**)
/ssd/src/gcc/git-svn/gcc/gimplify.c:6478
0xb8fbd2 gimplify_bind_expr
/ssd/src/gcc/git-svn/gcc/gimplify.c:1290
0xbb9938 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
/ssd/src/gcc/git-svn/gcc/gimplify.c:11391
0xba23ca gimplify_stmt(tree_node**, gimple**)
/ssd/src/gcc/git-svn/gcc/gimplify.c:6478
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
+ for n in 1 2 3 4 5
+ gcc -DTEST=5 -O2 -S -Wall -Wextra -Wpedantic
-fdump-tree-optimized=/dev/stdout t.c
t.c: In function ‘foo’:
t.c:31:18: warning: ISO C forbids braced-groups within expressions [-Wpedantic]
return (*({
^
;; Function foo (foo, funcdef_no=0, decl_uid=1795, cgraph_uid=0,
symbol_order=0)
foo ()
{
<bb 2> [100.00%]:
return 0;
}