]> git.unchartedbackwaters.co.uk Git - francis/stp.git/commitdiff
Silence some legitimate warnings about int to pointer casts that would
authorsmccam <smccam@e59a4935-1847-0410-ae03-e826735625c1>
Sat, 18 Dec 2010 02:32:20 +0000 (02:32 +0000)
committersmccam <smccam@e59a4935-1847-0410-ae03-e826735625c1>
Sat, 18 Dec 2010 02:32:20 +0000 (02:32 +0000)
fail on 64-bit systems by turning them into runtime assertions instead.

git-svn-id: https://stp-fast-prover.svn.sourceforge.net/svnroot/stp-fast-prover/trunk/stp@1037 e59a4935-1847-0410-ae03-e826735625c1

src/extlib-abc/vecAtt.h

index bef4f9f13cd0e9b0ace809221ba612b6827f3086..d2df49700996f668ce5ce079207dc990dc78a6df 100644 (file)
@@ -137,9 +137,13 @@ static inline void * Vec_AttFree( Vec_Att_t * p, int fFreeMan )
         int i;\r
         if ( p->pArrayInt )\r
         {\r
+            /* This code would not work on a 64-bit platform,\r
+               so let's hope it's unused. Though I've added a (long)\r
+               cast below to silence a relevant GCC warning. */\r
+            assert(sizeof(int) == sizeof(void *));\r
             for ( i = 0; i < p->nCap; i++ )\r
                 if ( p->pArrayInt[i] )\r
-                    p->pFuncFreeObj( p->pMan, (void *)p->pArrayInt[i] );\r
+                    p->pFuncFreeObj( p->pMan, (void *)(long)p->pArrayInt[i] );\r
         }\r
         else\r
         {\r
@@ -177,10 +181,15 @@ static inline void Vec_AttClear( Vec_Att_t * p )
         int i;\r
         if ( p->pArrayInt )\r
         {\r
-            if ( p->pFuncFreeObj )\r
+            if ( p->pFuncFreeObj ) {\r
+                /* This code would not work on a 64-bit platform,\r
+                   so let's hope it's unused. Though I've added a (long)\r
+                   cast below to silence a relevant GCC warning. */\r
+                assert(sizeof(int) == sizeof(void *));\r
                 for ( i = 0; i < p->nCap; i++ )\r
                     if ( p->pArrayInt[i] )\r
-                        p->pFuncFreeObj( p->pMan, (void *)p->pArrayInt[i] );\r
+                        p->pFuncFreeObj( p->pMan, (void *)(long)p->pArrayInt[i] );\r
+            }\r
         }\r
         else\r
         {\r
@@ -214,8 +223,13 @@ static inline void Vec_AttFreeEntry( Vec_Att_t * p, int i )
         return;\r
     if ( p->pMan )\r
     {\r
-        if ( p->pArrayInt[i] && p->pFuncFreeObj )\r
-            p->pFuncFreeObj( p->pMan, (void *)p->pArrayInt[i] );\r
+        if ( p->pArrayInt[i] && p->pFuncFreeObj ) {\r
+            /* This code would not work on a 64-bit platform,\r
+               so let's hope it's unused. Though I've added a (long)\r
+               cast below to silence a relevant GCC warning. */\r
+            assert(sizeof(int) == sizeof(void *));\r
+            p->pFuncFreeObj( p->pMan, (void *)(long)p->pArrayInt[i] );\r
+        }\r
         if ( p->pArrayPtr[i] && p->pFuncFreeObj )\r
             p->pFuncFreeObj( p->pMan, (void *)p->pArrayPtr[i] );\r
     }\r