On Thu, May 4, 2017 at 11:14 AM, Marek Polacek <pola...@redhat.com> wrote: > We need to check that the SSA_NAME we're passing down to get_range_info > is of INTEGRAL_TYPE_P; on pointers we'd crash on an assert. > > Bootstrapped/regtested on x86_64-linux, ok for trunk and 7.2?
Ok. Richard. > 2017-05-04 Marek Polacek <pola...@redhat.com> > > PR tree-optimization/80612 > * calls.c (get_size_range): Check for INTEGRAL_TYPE_P. > > * gcc.dg/torture/pr80612.c: New test. > > diff --git gcc/calls.c gcc/calls.c > index c26f157..bd081cc 100644 > --- gcc/calls.c > +++ gcc/calls.c > @@ -1270,7 +1270,7 @@ get_size_range (tree exp, tree range[2]) > > wide_int min, max; > enum value_range_type range_type > - = (TREE_CODE (exp) == SSA_NAME > + = ((TREE_CODE (exp) == SSA_NAME && INTEGRAL_TYPE_P (TREE_TYPE (exp))) > ? get_range_info (exp, &min, &max) : VR_VARYING); > > if (range_type == VR_VARYING) > diff --git gcc/testsuite/gcc.dg/torture/pr80612.c > gcc/testsuite/gcc.dg/torture/pr80612.c > index e69de29..225b811 100644 > --- gcc/testsuite/gcc.dg/torture/pr80612.c > +++ gcc/testsuite/gcc.dg/torture/pr80612.c > @@ -0,0 +1,15 @@ > +/* PR tree-optimization/80612 */ > +/* { dg-do compile } */ > + > +struct obstack *a; > +struct obstack { > + union { > + void *plain; > + void (*extra)(); > + } chunkfun; > +} fn1(void p4()) { > + a->chunkfun.plain = p4; > + a->chunkfun.extra(a); > +} > +void fn2(int) __attribute__((__alloc_size__(1))); > +void fn3() { fn1(fn2); } > > Marek