File tree 3 files changed +21
-1
lines changed
regression/ansi-c/Initializer_cast2
3 files changed +21
-1
lines changed Original file line number Diff line number Diff line change
1
+ int main ()
2
+ {
3
+ int A [(sizeof ((int []){1 , 2 , 3 })== 3 * sizeof (int ))?1 :-1 ];
4
+
5
+ return 0 ;
6
+ }
Original file line number Diff line number Diff line change
1
+ CORE
2
+ main.c
3
+
4
+ ^EXIT=0$
5
+ ^SIGNAL=0$
6
+ --
7
+ ^CONVERSION ERROR$
Original file line number Diff line number Diff line change @@ -1100,7 +1100,14 @@ void c_typecheck_baset::typecheck_expr_typecast(exprt &expr)
1100
1100
// or an expression for a pointer or scalar.
1101
1101
// We produce a compound_literal expression.
1102
1102
exprt tmp (ID_compound_literal, expr.type ());
1103
- tmp.move_to_operands (op);
1103
+ tmp.copy_to_operands (op);
1104
+
1105
+ // handle the case of TYPE being an array with unspecified size
1106
+ if (op.id ()==ID_array &&
1107
+ expr.type ().id ()==ID_array &&
1108
+ to_array_type (expr.type ()).size ().is_nil ())
1109
+ tmp.type ()=op.type ();
1110
+
1104
1111
expr=tmp;
1105
1112
expr.set (ID_C_lvalue, true ); // these are l-values
1106
1113
return ;
You can’t perform that action at this time.
0 commit comments