PR middle-end/92493 - ICE in get_origin_and_offset at gimple-ssa-sprintf.c
authorMartin Sebor <msebor@redhat.com>
Mon, 18 Nov 2019 22:14:16 +0000 (22:14 +0000)
committerMartin Sebor <msebor@gcc.gnu.org>
Mon, 18 Nov 2019 22:14:16 +0000 (15:14 -0700)
gcc/ChangeLog:

PR tree-optimization/92493
* gimple-ssa-sprintf.c (get_origin_and_offset): Remove spurious
assignment.

gcc/testsuite/ChangeLog:

PR tree-optimization/92493
* gcc.dg/pr92493.c: New test.

From-SVN: r278423

gcc/ChangeLog
gcc/gimple-ssa-sprintf.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr92493.c [new file with mode: 0644]

index 0c71cef37ac335ac4acef3a01436a787c25b88c6..11414b2384723c100f79a2ab028bf343817cc6df 100644 (file)
@@ -1,3 +1,9 @@
+2019-11-18  Martin Sebor  <msebor@redhat.com>
+
+       PR tree-optimization/92493
+       * gimple-ssa-sprintf.c (get_origin_and_offset): Remove spurious
+       assignment.
+
 2019-11-18  Giuliano Belinassi  <giuliano.belinassi@usp.br>
 
        * cfgloop.c (get_loop_body_in_custom_order): New.
index f6cd8e961dbe55d0f03b4eba52437bcef478670a..804a08675872ccfacdac59f8e08f8a25b6788437 100644 (file)
@@ -2346,7 +2346,6 @@ get_origin_and_offset (tree x, HOST_WIDE_INT *fldoff, HOST_WIDE_INT *off)
            {
              *fldoff += index;
              *off -= index;
-             fldoff = NULL;
            }
        }
 
index 83f704f090659e6bb3ebc3d754132b14b5a67dc6..199cd0547671b1b3ed4121d708215f7174f3a8f8 100644 (file)
@@ -1,3 +1,8 @@
+2019-11-18  Martin Sebor  <msebor@redhat.com>
+
+       PR tree-optimization/92493
+       * gcc.dg/pr92493.c: New test.
+
 2019-11-18  Joseph Myers  <joseph@codesourcery.com>
 
        * gcc.dg/c11-attr-syntax-1.c, gcc.dg/c11-attr-syntax-2.c,
diff --git a/gcc/testsuite/gcc.dg/pr92493.c b/gcc/testsuite/gcc.dg/pr92493.c
new file mode 100644 (file)
index 0000000..d301300
--- /dev/null
@@ -0,0 +1,29 @@
+/* PR middle-end/92493 - ICE in get_origin_and_offset at gimple-ssa-sprintf.c
+   { dg-do compile }
+   { dg-options "-O3 -Wall" } */
+
+struct A
+{
+  int i;
+  char a[2];
+} *p;
+
+struct B
+{
+  short j;
+  struct A a;
+} b;
+
+void warn (int j)
+{
+  struct A *q = &b.a;
+  p = q + j;
+  __builtin_snprintf (p->a, 8, "%s", p->a);   // { dg-warning "\\\[-Wrestrict" }
+}
+
+void nowarn (char *d, int j)
+{
+  struct A *q = &b.a;
+  p = q + j;
+  __builtin_snprintf (d, 8, "%s", p->a);
+}