POC: --- int f1 ( char * p ) ( ) { int x ; x = 4 ; if ( ! x != 10 ) return 1 ; if ( ( sum ( 1 , 2 ) / 2 ) != 1 ) return 1 ; if ( - ( 2 * sum ( 3 , 4 ) + sum ( ( union foo { int i , X [ 2 ] [ - ( 100.000000 / 2 ) * 2 ] , k ; char * p ; float ( * f1 ( int a , int b ) ) ( int c , int b ) ; } ) p , 2 ) ) != 0 - 4 ) return 1 ; return 0 ; } --- Gcc version: --- Using built-in specs. COLLECT_GCC=/mnt/raidhhd/gcc_instr_install/usr/local/bin/gcc COLLECT_LTO_WRAPPER=/mnt/raidhhd/gcc_instr_install/usr/local/bin/../libexec/gcc/x86_64-pc-linux-gnu/10.0.1/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: ../configure Thread model: posix Supported LTO compression algorithms: zlib gcc version 10.0.1 20200127 (experimental) (GCC) --- CMD: --- gcc -o tmp poc.c ---
Stack dump: --- tt.c:1:5: error: ‘f1’ declared as function returning a function 1 | int f1 ( char * p ) ( ) { int x ; | ^~ tt.c: In function ‘f1’: tt.c:4:9: warning: implicit declaration of function ‘sum’ [-Wimplicit-function-declaration] 4 | if ( ( sum ( 1 , 2 ) / 2 ) != 1 ) return 1 ; | ^~~ tt.c:5:60: error: size of array ‘X’ has non-integer type 5 | if ( - ( 2 * sum ( 3 , 4 ) + sum ( ( union foo { int i , X [ 2 ] [ - ( 100.000000 / 2 ) * 2 ] , k ; | ^ tt.c:7:34: error: field ‘f1’ declared as a function 7 | float ( * f1 ( int a , int b ) ) ( int c , int b ) ; | ^~ tt.c:5:32: internal compiler error: in force_constant_size, at gimplify.c:733 5 | if ( - ( 2 * sum ( 3 , 4 ) + sum ( ( union foo { int i , X [ 2 ] [ - ( 100.000000 / 2 ) * 2 ] , k ; | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6 | char * p ; | ~~~~~~~~~~ 7 | float ( * f1 ( int a , int b ) ) ( int c , int b ) ; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 8 | } ) p , 2 ) ) != 0 - 4 ) return 1 ; | ~~~~~~~~~~~~~ 0x69d4dc force_constant_size ../../gcc/gimplify.c:733 0xb1b637 gimple_add_tmp_var(tree_node*) ../../gcc/gimplify.c:771 0xae9287 create_tmp_var(tree_node*, char const*) ../../gcc/gimple-expr.c:485 0xb2d5df create_tmp_from_val ../../gcc/gimplify.c:561 0xb2d5df lookup_tmp_var ../../gcc/gimplify.c:582 0xb2d5df internal_get_tmp_var ../../gcc/gimplify.c:635 0xb26ccf get_formal_tmp_var(tree_node*, gimple**) ../../gcc/gimplify.c:663 0xb26ccf gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*), int) ../../gcc/gimplify.c:14582 0xb287c6 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*), int) ../../gcc/gimplify.c:14030 0xb314b4 gimplify_expr ../../gcc/gimplify.c:14628 0xb33335 gimplify_call_expr ../../gcc/gimplify.c:3497 0xb28467 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*), int) ../../gcc/gimplify.c:13553 0xb27790 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*), int) ../../gcc/gimplify.c:14350 0xb27757 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*), int) ../../gcc/gimplify.c:14348 0xb3cdbb gimplify_cond_expr ../../gcc/gimplify.c:4177 0xb27ece gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*), int) ../../gcc/gimplify.c:13538 0xb2af96 gimplify_stmt(tree_node**, gimple**) ../../gcc/gimplify.c:6822 0xb2885b gimplify_statement_list ../../gcc/gimplify.c:1869 0xb2885b gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*), int) ../../gcc/gimplify.c:14025 0xb2af96 gimplify_stmt(tree_node**, gimple**) ../../gcc/gimplify.c:6822 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. ---
Confirmed. Bisection points to r256748 (GCC 8): commit 47c268c4b27782717fbccec5019e0cd97d005afb Author: Jakub Jelinek <jakub@redhat.com> Date: Tue Jan 16 16:18:24 2018 +0100 re PR libgomp/83590 ([nvptx] openacc reduction C regressions) PR libgomp/83590 * gimplify.c (gimplify_one_sizepos): For is_gimple_constant (expr) return early, inline manually is_gimple_sizepos. Make sure if we call gimplify_expr we don't end up with a gimple constant. * tree.c (variably_modified_type_p): Don't return true for is_gimple_constant (_t). Inline manually is_gimple_sizepos. * gimplify.h (is_gimple_sizepos): Remove. Co-Authored-By: Richard Biener <rguenther@suse.de> From-SVN: r256748
Reduced testcase: void bar (); void foo (char a) { union C { int d[100.0]; char *e; }; bar ((union C) &a); }
Created attachment 48135 [details] gcc10-pr93573.patch For the error-recovery ICE, we can just make sure that after errors the type isn't assumed to be VLA. Unfortunately: void bar (); void foo (char a, int b) { union C { int d[b]; char *e; }; bar ((union C) &a); } still ICEs.
The master branch has been updated by Jakub Jelinek <jakub@gcc.gnu.org>: https://gcc.gnu.org/g:c6a562de88c44a555e1688c212869b20b02151bc commit r10-7438-gc6a562de88c44a555e1688c212869b20b02151bc Author: Jakub Jelinek <jakub@redhat.com> Date: Sat Mar 28 10:30:31 2020 +0100 c: After issuing errors about array size, for error-recovery don't make the array VLA [PR93573] After we report various errors about array size, we set for error-recovery the size to be 1, but because size_int_const is false, it still means we pretend the array is a VLA, can emit a second diagnostics in that case etc. E.g. $ ./cc1.unpatched -quiet a.c a.c:1:5: error: size of array âfâ has non-integer type 1 | int f[100.0]; | ^ a.c:1:1: warning: variably modified âfâ at file scope 1 | int f[100.0]; | ^~~ $ ./cc1 -quiet a.c a.c:1:5: error: size of array âfâ has non-integer type 1 | int f[100.0]; | ^ 2020-03-28 Jakub Jelinek <jakub@redhat.com> PR c/93573 * c-decl.c (grokdeclarator): After issuing errors, set size_int_const to true after setting size to integer_one_node. * gcc.dg/pr93573-1.c: New test. * gcc.dg/pr93573-2.c: New test.
Fixed the error-recovery bug on the trunk, but the ice on the #c4 testcase is still there (and the question is if it is valid or not). If it is valid, probably the FE or gimplifier needs to turn that cast to VLA union into creation of a VLA temporary and assigning the cast operand into the right field of it.
Passing a variable-size struct or union by value to a non-nested function seems very questionable (the function couldn't be declared with a matching prototype), but perhaps that doesn't answer the question because the cast-to-union case might appear for a nested function as well.
GCC 8 branch is being closed.
GCC 9.4 is being released, retargeting bugs to GCC 9.5.
GCC 9 branch is being closed
GCC 10.4 is being released, retargeting bugs to GCC 10.5.
GCC 10 branch is being closed.
(In reply to Jakub Jelinek from comment #6) > Fixed the error-recovery bug on the trunk, but the ice on the #c4 testcase > is still there (and the question is if it is valid or not). If it is valid, > probably the FE or gimplifier needs to turn that cast to VLA union into > creation of a VLA temporary and assigning the cast operand into the right > field of it. Hmm, is the testcase in comment #4 a regression though? It ICEs even in the same way in GCC 4.1.2 all the way to the trunk including GCC 7.3.0.
(In reply to Andrew Pinski from comment #13) > Hmm, is the testcase in comment #4 a regression though? It ICEs even in the > same way in GCC 4.1.2 all the way to the trunk including GCC 7.3.0. It is. gcc 3.2, 3.3 and 3.4 at least compile that just fine, while r0-63127-ga63c0d13291b93a42e927d0356b2d9854c654337 ICEs.
GCC 11 branch is being closed.