https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95002
Bug ID: 95002 Summary: VLA: 'var = sizeof array' gives spurous '= array, <size expr>' instead of just '= <size expr>' Product: gcc Version: 10.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: burnus at gcc dot gnu.org Target Milestone: --- [Cf. PR94874 and PR 90859; the extra 'array' is exposed to OpenMP and makes a difference there.] The following code (assuming size_t == unsigned long): void f1(int len_1) {int arr1[len_1]; int size1 = sizeof arr1; } void f2(int len_2) {int arr2[len_2]; unsigned long size2 = sizeof arr2; } Gives a spurious '= array,' is the LHS and the RHS have the same type: int size1 = (int) ((unsigned int) (sizetype) SAVE_EXPR <len_1> * 4); long unsigned int size2 = arr2, (long unsigned int) ((sizetype) SAVE_EXPR <len_2> * 4);; The code starts to differ at c/c-typeck.c's digest_init() when the second code (size_t on LHS) enters the "if (inside_init' – as the compound_expr 'inside_init' has the same type as the (lhs) 'type'. That's fixed by: --- a/gcc/c/c-typeck.c +++ b/gcc/c/c-typeck.c @@ -7974 +7974,2 @@ digest_init (location_t init_loc, tree type, tree init, - if (TREE_CODE (TREE_TYPE (inside_init)) == POINTER_TYPE) + if (TREE_CODE (TREE_TYPE (inside_init)) == POINTER_TYPE + || TREE_CODE (TREE_TYPE (inside_init)) == INTEGER_TYPE) However, despite having then an identical 'convert_for_assignment' call, the result is still different. Debugging continues …