re PR sanitizer/56990 (ICE: SIGFPE with -fsanitize=thread and empty struct)
authorMarek Polacek <polacek@redhat.com>
Mon, 22 Apr 2013 17:02:49 +0000 (17:02 +0000)
committerMarek Polacek <mpolacek@gcc.gnu.org>
Mon, 22 Apr 2013 17:02:49 +0000 (17:02 +0000)
PR sanitizer/56990
* tsan.c (instrument_expr): Don't instrument expression
in case its size is zero.

* gcc.dg/pr56990.c: New test.

From-SVN: r198147

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr56990.c [new file with mode: 0644]
gcc/tsan.c

index ce29ccebb476a5212a7dfbc001478679d76dd4dc..f5b463574d91fa924c8ee2f3acdd8174221a6f13 100644 (file)
@@ -1,3 +1,9 @@
+2013-04-22  Marek Polacek  <polacek@redhat.com>
+
+       PR sanitizer/56990
+       * tsan.c (instrument_expr): Don't instrument expression
+       in case its size is zero.
+
 2013-04-22  Uros Bizjak  <ubizjak@gmail.com>
 
        PR target/57032
index 3917bbe7111cdb328ba5805db998fd9ca00617a9..84a1fb9474b630abffc98be14dc02b81af24751e 100644 (file)
@@ -1,3 +1,8 @@
+2013-04-22  Marek Polacek  <polacek@redhat.com>
+
+       PR sanitizer/56990
+       * gcc.dg/pr56990.c: New test.
+
 2013-04-22  Vladimir Makarov  <vmakarov@redhat.com>
 
        PR target/57018
diff --git a/gcc/testsuite/gcc.dg/pr56990.c b/gcc/testsuite/gcc.dg/pr56990.c
new file mode 100644 (file)
index 0000000..ecb6ace
--- /dev/null
@@ -0,0 +1,10 @@
+/* PR sanitizer/56990 */
+/* { dg-do compile { target { x86_64-*-linux* && lp64 } } } */
+/* { dg-options "-fsanitize=thread" } */
+
+struct S{};
+
+void foo(struct S *p)
+{
+  *p = (struct S){};
+}
index c02e100cca0695bfc8839e3927d39f7e4f29de87..79b8bc395d3b60ae677deb5ecb4f2b563c975b48 100644 (file)
@@ -131,7 +131,8 @@ instrument_expr (gimple_stmt_iterator gsi, tree expr, bool is_write)
   if (TREE_READONLY (base))
     return false;
 
-  if (bitpos % (size * BITS_PER_UNIT)
+  if (size == 0
+      || bitpos % (size * BITS_PER_UNIT)
       || bitsize != size * BITS_PER_UNIT)
     return false;