re PR sanitizer/81209 (-fsanitize=undefined ICE on darwin)
authorJakub Jelinek <jakub@redhat.com>
Tue, 27 Jun 2017 07:23:54 +0000 (09:23 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 27 Jun 2017 07:23:54 +0000 (09:23 +0200)
PR sanitizer/81209
* ubsan.c (ubsan_encode_value): Initialize DECL_CONTEXT on var.

* g++.dg/ubsan/pr81209.C: New test.

From-SVN: r249678

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/ubsan/pr81209.C [new file with mode: 0644]
gcc/ubsan.c

index e9dc0d6f2bac71fd21d95d2803de9acd3ec4b41f..128e8f7d726d3eae62a6476e44e7d6319ee666c6 100644 (file)
@@ -1,5 +1,8 @@
 2017-06-27  Jakub Jelinek  <jakub@redhat.com>
 
+       PR sanitizer/81209
+       * ubsan.c (ubsan_encode_value): Initialize DECL_CONTEXT on var.
+
        PR middle-end/81207
        * gimple-fold.c (replace_call_with_call_and_fold): Handle
        gimple_vuse copying separately from gimple_vdef copying.
index 0217b7f0beef7c6c2dc185c1291e99d4f729a24a..fecfd6211ae260bd372c5349b401eb78330fb917 100644 (file)
@@ -1,5 +1,8 @@
 2017-06-27  Jakub Jelinek  <jakub@redhat.com>
 
+       PR sanitizer/81209
+       * g++.dg/ubsan/pr81209.C: New test.
+
        PR middle-end/81207
        * gcc.c-torture/compile/pr81207.c: New test.
 
diff --git a/gcc/testsuite/g++.dg/ubsan/pr81209.C b/gcc/testsuite/g++.dg/ubsan/pr81209.C
new file mode 100644 (file)
index 0000000..3f2a576
--- /dev/null
@@ -0,0 +1,21 @@
+// PR sanitizer/81209
+// { dg-do compile }
+// { dg-options "-fsanitize=undefined -fno-declone-ctor-dtor" }
+
+#ifdef __SIZEOF_INT128__
+typedef __int128 T;
+#else
+typedef long long int T;
+#endif
+
+struct B {};
+struct A : virtual public B
+{
+  A (long);
+  T a;
+};
+
+A::A (long c)
+{
+  long b = a % c;
+}
index 44effdd22166d0b35fa95a71dd40a0eb89990bf3..c7a06ef0e8ddfb8ab844e5970766bf9c2d8e43d5 100644 (file)
@@ -153,6 +153,7 @@ ubsan_encode_value (tree t, enum ubsan_encode_value_phase phase)
            {
              var = create_tmp_var_raw (type);
              TREE_ADDRESSABLE (var) = 1;
+             DECL_CONTEXT (var) = current_function_decl;
            }
          if (phase == UBSAN_ENCODE_VALUE_RTL)
            {