Description: do not hardcode 64-bit pointer widths
 .
 cbmc (5.12-1) unstable; urgency=low
 .
   * New upstream release
   * Updated Standards version to 4.5.0.1 (no changes required)
   * Acknowledge NMU - thanks Adrian for the build fix (Closes: #952256)
Author: Michael Tautschnig <mt@debian.org>
Bug-Debian: https://bugs.debian.org/952256

---
The information above should follow the Patch Tagging Guidelines, please
checkout http://dep.debian.net/deps/dep3/ to learn about the format. Here
are templates for supplementary fields that you might want to add:

Origin: <vendor|upstream|other>, <url of original patch>
Bug: <url in upstream bugtracker>
Bug-Debian: https://bugs.debian.org/<bugnumber>
Bug-Ubuntu: https://launchpad.net/bugs/<bugnumber>
Forwarded: <no|not-needed|url proving that it has been forwarded>
Reviewed-By: <name and email of someone who approved the patch>
Last-Update: 2020-04-24

--- cbmc-5.12.orig/unit/pointer-analysis/value_set.cpp
+++ cbmc-5.12/unit/pointer-analysis/value_set.cpp
@@ -14,6 +14,7 @@ Author: Diffblue Ltd.
 #include <pointer-analysis/value_set.h>
 #include <util/arith_tools.h>
 #include <util/byte_operators.h>
+#include <util/c_types.h>
 
 static bool object_descriptor_matches(
   const exprt &descriptor_expr, const exprt &target)
@@ -47,8 +48,8 @@ SCENARIO(
   {
     // Create struct A { A *x; A *y }
 
-    struct_typet struct_A({{"x", pointer_typet(struct_tag_typet("A"), 64)},
-                           {"y", pointer_typet(struct_tag_typet("A"), 64)}});
+    struct_typet struct_A({{"x", pointer_type(struct_tag_typet("A"))},
+                           {"y", pointer_type(struct_tag_typet("A"))}});
     struct_A.set_tag("A");
 
     auto &A_x = struct_A.components()[0];
@@ -227,7 +228,7 @@ SCENARIO(
   {
     // Make some global integers i1, i2, i3:
     signedbv_typet int32_type(32);
-    pointer_typet int32_ptr(int32_type, 64);
+    pointer_typet int32_ptr = pointer_type(int32_type);
 
     symbolt i1;
     i1.name = "i1";
--- cbmc-5.12.orig/regression/cbmc/assigning_nullpointers_should_not_crash_symex/main.c
+++ cbmc-5.12/regression/cbmc/assigning_nullpointers_should_not_crash_symex/main.c
@@ -1,4 +1,5 @@
 #include <assert.h>
+#include <stdint.h>
 #include <stdlib.h>
 
 struct linked_list
@@ -8,7 +9,13 @@ struct linked_list
 
 int main(void)
 {
+#if UINTPTR_MAX == UINT64_MAX
   size_t list_sz = 8ul;
+#elif UINTPTR_MAX == UINT32_MAX
+  size_t list_sz = 4ul;
+#else
+#error Unsupported platform
+#endif
   assert(list_sz == sizeof(struct linked_list));
   struct linked_list *list = malloc(list_sz);
   // this line makes symex crash for some reason
--- cbmc-5.12.orig/regression/goto-harness/CMakeLists.txt
+++ cbmc-5.12/regression/goto-harness/CMakeLists.txt
@@ -10,3 +10,19 @@ add_test_pl_tests(
    $<TARGET_FILE:goto-harness> \
    $<TARGET_FILE:cbmc> \
    ${is_windows}")
+
+if(CMAKE_SIZEOF_VOID_P EQUAL 8)
+    add_custom_command(OUTPUT "${CMAKE_CURRENT_SOURCE_DIR}/load-snapshot-static-global-pointer-01/snapshot.json"
+        COMMAND ${CMAKE_COMMAND} -E copy snapshot64.json snapshot.json
+        WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/load-snapshot-static-global-pointer-01"
+    )
+else()
+    add_custom_command(OUTPUT "${CMAKE_CURRENT_SOURCE_DIR}/load-snapshot-static-global-pointer-01/snapshot.json"
+        COMMAND ${CMAKE_COMMAND} -E copy snapshot32.json snapshot.json
+        WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/load-snapshot-static-global-pointer-01"
+    )
+endif()
+
+add_custom_target(snapshot.json ALL
+    DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/load-snapshot-static-global-pointer-01/snapshot.json"
+)
--- cbmc-5.12.orig/regression/goto-harness/Makefile
+++ cbmc-5.12/regression/goto-harness/Makefile
@@ -20,6 +20,18 @@ test:
 tests.log: ../test.pl
 	@../test.pl -e -p -c "../chain.sh $(GOTO_CC_EXE) $(GOTO_HARNESS_EXE) $(CBMC_EXE) $(is_windows)"
 
+test tests.log: load-snapshot-static-global-pointer-01/snapshot.json
+load-snapshot-static-global-pointer-01/snapshot.json:
+ifeq ($(BUILD_ENV_),MSVC)
+	if [ `uname -m` = "x86_64" ] ; then \
+		cp $(dir $@)/snapshot64.json $@ ; \
+	else \
+		cp $(dir $@)/snapshot32.json $@ ; \
+	fi
+else
+	BIT_WIDTH=`getconf LONG_BIT` ; cp $(dir $@)/snapshot$$BIT_WIDTH.json $@
+endif
+
 show:
 	@for dir in *; do \
 		if [ -d "$$dir" ]; then \
@@ -31,3 +43,4 @@ clean:
 	find -name '*.out' -execdir $(RM) '{}' \;
 	find -name '*.gb' -execdir $(RM) {} \;
 	$(RM) tests.log
+	$(RM) load-snapshot-static-global-pointer-01/snapshot.json
--- /dev/null
+++ cbmc-5.12/regression/goto-harness/load-snapshot-static-global-pointer-01/snapshot32.json
@@ -0,0 +1,102 @@
+{
+  "symbolTable": {
+    "p": {
+      "baseName": "p",
+      "isAuxiliary": false,
+      "isExported": false,
+      "isExtern": false,
+      "isFileLocal": false,
+      "isInput": false,
+      "isLvalue": true,
+      "isMacro": false,
+      "isOutput": false,
+      "isParameter": false,
+      "isProperty": false,
+      "isStateVar": false,
+      "isStaticLifetime": true,
+      "isThreadLocal": false,
+      "isType": false,
+      "isVolatile": false,
+      "isWeak": false,
+      "location": {},
+      "mode": "C",
+      "module": "main",
+      "name": "p",
+      "prettyName": "p",
+      "type": {
+        "id": "pointer",
+        "namedSub": {
+          "#source_location": {},
+          "width": {
+            "id": "32"
+          }
+        },
+        "sub": [
+          {
+            "id": "signedbv",
+            "namedSub": {
+              "#c_type": {
+                "id": "signed_int"
+              },
+              "width": {
+                "id": "32"
+              }
+            }
+          }
+        ]
+      },
+      "value": {
+        "id": "address_of",
+        "namedSub": {
+          "#source_location": {},
+          "type": {
+            "id": "pointer",
+            "namedSub": {
+              "width": {
+                "id": "32"
+              }
+            },
+            "sub": [
+              {
+                "id": "signedbv",
+                "namedSub": {
+                  "#c_type": {
+                    "id": "signed_int"
+                  },
+                  "width": {
+                    "id": "32"
+                  }
+                }
+              }
+            ]
+          }
+        },
+        "sub": [
+          {
+            "id": "symbol",
+            "namedSub": {
+              "#lvalue": {
+                "id": "1"
+              },
+              "#source_location": {},
+              "identifier": {
+                "id": "x"
+              },
+              "type": {
+                "id": "signedbv",
+                "namedSub": {
+                  "#c_type": {
+                    "id": "signed_int"
+                  },
+                  "width": {
+                    "id": "32"
+                  }
+                }
+              }
+            }
+          }
+        ]
+      }
+    }
+  }
+}
--- /dev/null
+++ cbmc-5.12/regression/goto-harness/load-snapshot-static-global-pointer-01/snapshot64.json
@@ -0,0 +1,102 @@
+{
+  "symbolTable": {
+    "p": {
+      "baseName": "p",
+      "isAuxiliary": false,
+      "isExported": false,
+      "isExtern": false,
+      "isFileLocal": false,
+      "isInput": false,
+      "isLvalue": true,
+      "isMacro": false,
+      "isOutput": false,
+      "isParameter": false,
+      "isProperty": false,
+      "isStateVar": false,
+      "isStaticLifetime": true,
+      "isThreadLocal": false,
+      "isType": false,
+      "isVolatile": false,
+      "isWeak": false,
+      "location": {},
+      "mode": "C",
+      "module": "main",
+      "name": "p",
+      "prettyName": "p",
+      "type": {
+        "id": "pointer",
+        "namedSub": {
+          "#source_location": {},
+          "width": {
+            "id": "64"
+          }
+        },
+        "sub": [
+          {
+            "id": "signedbv",
+            "namedSub": {
+              "#c_type": {
+                "id": "signed_int"
+              },
+              "width": {
+                "id": "32"
+              }
+            }
+          }
+        ]
+      },
+      "value": {
+        "id": "address_of",
+        "namedSub": {
+          "#source_location": {},
+          "type": {
+            "id": "pointer",
+            "namedSub": {
+              "width": {
+                "id": "64"
+              }
+            },
+            "sub": [
+              {
+                "id": "signedbv",
+                "namedSub": {
+                  "#c_type": {
+                    "id": "signed_int"
+                  },
+                  "width": {
+                    "id": "32"
+                  }
+                }
+              }
+            ]
+          }
+        },
+        "sub": [
+          {
+            "id": "symbol",
+            "namedSub": {
+              "#lvalue": {
+                "id": "1"
+              },
+              "#source_location": {},
+              "identifier": {
+                "id": "x"
+              },
+              "type": {
+                "id": "signedbv",
+                "namedSub": {
+                  "#c_type": {
+                    "id": "signed_int"
+                  },
+                  "width": {
+                    "id": "32"
+                  }
+                }
+              }
+            }
+          }
+        ]
+      }
+    }
+  }
+}
--- cbmc-5.12/regression/goto-harness/load-snapshot-static-global-pointer-01/snapshot.json
+++ cbmc-5.12/regression/goto-harness/load-snapshot-static-global-pointer-01/snapshot.json
@@ -1,102 +0,0 @@
-{
-  "symbolTable": {
-    "p": {
-      "baseName": "p",
-      "isAuxiliary": false,
-      "isExported": false,
-      "isExtern": false,
-      "isFileLocal": false,
-      "isInput": false,
-      "isLvalue": true,
-      "isMacro": false,
-      "isOutput": false,
-      "isParameter": false,
-      "isProperty": false,
-      "isStateVar": false,
-      "isStaticLifetime": true,
-      "isThreadLocal": false,
-      "isType": false,
-      "isVolatile": false,
-      "isWeak": false,
-      "location": {},
-      "mode": "C",
-      "module": "main",
-      "name": "p",
-      "prettyName": "p",
-      "type": {
-        "id": "pointer",
-        "namedSub": {
-          "#source_location": {},
-          "width": {
-            "id": "64"
-          }
-        },
-        "sub": [
-          {
-            "id": "signedbv",
-            "namedSub": {
-              "#c_type": {
-                "id": "signed_int"
-              },
-              "width": {
-                "id": "32"
-              }
-            }
-          }
-        ]
-      },
-      "value": {
-        "id": "address_of",
-        "namedSub": {
-          "#source_location": {},
-          "type": {
-            "id": "pointer",
-            "namedSub": {
-              "width": {
-                "id": "64"
-              }
-            },
-            "sub": [
-              {
-                "id": "signedbv",
-                "namedSub": {
-                  "#c_type": {
-                    "id": "signed_int"
-                  },
-                  "width": {
-                    "id": "32"
-                  }
-                }
-              }
-            ]
-          }
-        },
-        "sub": [
-          {
-            "id": "symbol",
-            "namedSub": {
-              "#lvalue": {
-                "id": "1"
-              },
-              "#source_location": {},
-              "identifier": {
-                "id": "x"
-              },
-              "type": {
-                "id": "signedbv",
-                "namedSub": {
-                  "#c_type": {
-                    "id": "signed_int"
-                  },
-                  "width": {
-                    "id": "32"
-                  }
-                }
-              }
-            }
-          }
-        ]
-      }
-    }
-  }
-}
--- cbmc-5.12.orig/src/statement-list/statement_list_typecheck.cpp
+++ cbmc-5.12/src/statement-list/statement_list_typecheck.cpp
@@ -13,6 +13,8 @@ Author: Matthias Weiss, matthias.weiss@d
 #include "converters/statement_list_types.h"
 
 #include <iostream>
+
+#include <util/c_types.h>
 #include <util/ieee_float.h>
 #include <util/message.h>
 #include <util/namespace.h>
@@ -21,8 +23,6 @@ Author: Matthias Weiss, matthias.weiss@d
 #include <util/std_expr.h>
 #include <util/std_types.h>
 
-/// Size of pointers in Siemens TIA.
-#define STATEMENT_LIST_PTR_WIDTH 64
 // TODO: Replace with more specific exception throws.
 #define TYPECHECK_ERROR 0
 /// Artificial name for the data block interface of a function block.
@@ -46,7 +46,7 @@ static code_typet::parametert create_dat
   const struct_typet &data_block_type,
   const irep_idt &function_block_name)
 {
-  const pointer_typet db_ptr{data_block_type, STATEMENT_LIST_PTR_WIDTH};
+  const auto db_ptr = pointer_type(data_block_type);
   code_typet::parametert param{db_ptr};
   param.set_identifier(
     id2string(function_block_name) + "::" + DATA_BLOCK_PARAMETER_NAME);
