File tree 5 files changed +36
-10
lines changed
5 files changed +36
-10
lines changed Original file line number Diff line number Diff line change
1
+ extern int stuff [];
2
+
3
+ extern int a [];
4
+ int a [] = {1 , 2 , 3 };
5
+
6
+ int main ()
7
+ {
8
+ unsigned char idx ;
9
+ long val = * (long * )(stuff + idx );
10
+ __CPROVER_assert (val == 13 , "compare" );
11
+ return 0 ;
12
+ }
Original file line number Diff line number Diff line change
1
+ CORE new-smt-backend
2
+ main.c
3
+
4
+ ^EXIT=10$
5
+ ^SIGNAL=0$
6
+ ^VERIFICATION FAILED$
7
+ --
8
+ ^warning: ignoring
9
+ ^Invariant check failed
Original file line number Diff line number Diff line change @@ -314,7 +314,7 @@ void c_typecheck_baset::typecheck_redefinition_non_type(
314
314
315
315
if (
316
316
final_old.id () == ID_array &&
317
- to_array_type (final_old).size ().is_not_nil () &&
317
+ to_array_type (final_old).size ().is_not_nil () && !old_symbol. is_weak &&
318
318
initial_new.id () == ID_array &&
319
319
to_array_type (initial_new).size ().is_nil () &&
320
320
to_array_type (final_old).element_type () ==
@@ -504,7 +504,8 @@ void c_typecheck_baset::typecheck_redefinition_non_type(
504
504
if (final_old!=final_new)
505
505
{
506
506
if (
507
- final_old.id () == ID_array && to_array_type (final_old).size ().is_nil () &&
507
+ final_old.id () == ID_array &&
508
+ (to_array_type (final_old).size ().is_nil () || old_symbol.is_weak ) &&
508
509
final_new.id () == ID_array &&
509
510
to_array_type (final_new).size ().is_not_nil () &&
510
511
to_array_type (final_old).element_type () ==
Original file line number Diff line number Diff line change @@ -249,6 +249,15 @@ void c_typecheck_baset::do_initializer(symbolt &symbol)
249
249
if (!symbol.is_macro && symbol.type != symbol.value .type ())
250
250
symbol.type = symbol.value .type ();
251
251
}
252
+ else if (
253
+ symbol.type .id () == ID_array && to_array_type (symbol.type ).size ().is_nil ())
254
+ {
255
+ // C standard 6.9.2, paragraph 5
256
+ // adjust the type to an array of size 1, but mark as weak so that linking
257
+ // can change that
258
+ to_array_type (symbol.type ).size () = from_integer (1 , size_type ());
259
+ symbol.is_weak = true ;
260
+ }
252
261
253
262
if (symbol.is_macro )
254
263
make_constant (symbol.value );
Original file line number Diff line number Diff line change @@ -50,14 +50,9 @@ static optionalt<codet> static_lifetime_init(
50
50
if (type.id () == ID_code || type.id () == ID_empty)
51
51
return {};
52
52
53
- if (type.id () == ID_array && to_array_type (type).size ().is_nil ())
54
- {
55
- // C standard 6.9.2, paragraph 5
56
- // adjust the type to an array of size 1
57
- symbolt &writable_symbol = symbol_table.get_writeable_ref (identifier);
58
- writable_symbol.type = type;
59
- writable_symbol.type .set (ID_size, from_integer (1 , size_type ()));
60
- }
53
+ DATA_INVARIANT (
54
+ type.id () != ID_array || to_array_type (type).size ().is_not_nil (),
55
+ " arrays must have a size" );
61
56
62
57
if (
63
58
(type.id () == ID_struct || type.id () == ID_union) &&
You can’t perform that action at this time.
0 commit comments