File tree 4 files changed +45
-1
lines changed
4 files changed +45
-1
lines changed Original file line number Diff line number Diff line change
1
+ #include <assert.h>
2
+ #include <stdint.h>
3
+
4
+ int main ()
5
+ {
6
+ union {
7
+ intptr_t i ;
8
+ int * p ;
9
+ } u ;
10
+ u .i = 0 ;
11
+ assert (u .p == 0 );
12
+ }
Original file line number Diff line number Diff line change
1
+ CORE broken-smt-backend
2
+ main.c
3
+ --arch none --little-endian
4
+ (Starting CEGAR Loop|^Generated 1 VCC\(s\), 1 remaining after simplification$)
5
+ ^EXIT=0$
6
+ ^SIGNAL=0$
7
+ ^VERIFICATION SUCCESSFUL$
8
+ --
9
+ ^warning: ignoring
Original file line number Diff line number Diff line change
1
+ CORE
2
+ main.c
3
+
4
+ ^EXIT=0$
5
+ ^SIGNAL=0$
6
+ ^VERIFICATION SUCCESSFUL$
7
+ --
8
+ ^warning: ignoring
Original file line number Diff line number Diff line change @@ -1357,8 +1357,23 @@ bool simplify_exprt::simplify_inequality(exprt &expr)
1357
1357
{
1358
1358
if (expr.id () == ID_equal || expr.id () == ID_notequal)
1359
1359
{
1360
-
1360
+ // two constants compare equal when there values (as strings) are the same
1361
+ // or both of them are pointers and both represent NULL in some way
1361
1362
bool equal = (tmp0_const->get_value () == tmp1_const->get_value ());
1363
+ if (
1364
+ !equal && tmp0_const->type ().id () == ID_pointer &&
1365
+ tmp1_const->type ().id () == ID_pointer)
1366
+ {
1367
+ if (
1368
+ !config.ansi_c .NULL_is_zero && (tmp0_const->get_value () == ID_NULL ||
1369
+ tmp1_const->get_value () == ID_NULL))
1370
+ {
1371
+ // if NULL is not zero on this platform, we really don't know what it
1372
+ // is and therefore cannot simplify
1373
+ return true ;
1374
+ }
1375
+ equal = tmp0_const->is_zero () && tmp1_const->is_zero ();
1376
+ }
1362
1377
expr.make_bool (expr.id () == ID_equal ? equal : !equal);
1363
1378
return false ;
1364
1379
}
You can’t perform that action at this time.
0 commit comments