[committed] remove spurious assignment to avoid ICE (PR 92493)
diff mbox series

Message ID 3e1a5e40-601b-9942-6c29-980a9fdf16c8@redhat.com
State New
Headers show
Series
  • [committed] remove spurious assignment to avoid ICE (PR 92493)
Related show

Commit Message

Martin Sebor Nov. 18, 2019, 10:18 p.m. UTC
I checked in the attached change in r278423 to avoid the ICE
reported in the PR and introduced in a recent commit of mine.
The change was bootstrapped and regtested on x86_64-linux.

Martin

Patch
diff mbox series

PR middle-end/92493 - ICE in get_origin_and_offset at gimple-ssa-sprintf.c

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.

Index: gcc/gimple-ssa-sprintf.c
===================================================================
--- gcc/gimple-ssa-sprintf.c	(revision 278418)
+++ gcc/gimple-ssa-sprintf.c	(working copy)
@@ -2346,7 +2346,6 @@  get_origin_and_offset (tree x, HOST_WIDE_INT *fldo
 	    {
 	      *fldoff += index;
 	      *off -= index;
-	      fldoff = NULL;
 	    }
 	}
 
Index: gcc/testsuite/gcc.dg/pr92493.c
===================================================================
--- gcc/testsuite/gcc.dg/pr92493.c	(nonexistent)
+++ gcc/testsuite/gcc.dg/pr92493.c	(working copy)
@@ -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);
+}