Hi, this patch fixes ICE on type inconsistent programs where vtable pointer is worked out to be arbitrary pointer to something else.
Bootstrapped/regtested x86_64-linux, comitted. Honza Index: ChangeLog =================================================================== --- ChangeLog (revision 220176) +++ ChangeLog (working copy) @@ -1,3 +1,9 @@ +2015-01-27 Jan Hubicka <hubi...@ucw.cz> + + PR ipa/64282 + * gimple-fold.c (gimple_get_virt_method_for_vtable): Remove assert + on vtable being vtable. + 2015-01-27 Dominik Vogt <v...@linux.vnet.ibm.com> * doc/extend.texi: s/390: Update documentation of hotpatch attribute. Index: testsuite/ChangeLog =================================================================== --- testsuite/ChangeLog (revision 220176) +++ testsuite/ChangeLog (working copy) @@ -1,3 +1,8 @@ +2015-01-27 Jan Hubicka <hubi...@ucw.cz> + + PR ipa/64282 + * g++.dg/torture/pr64282.C: New testcase. + 2015-01-27 Kyrylo Tkachov <kyrylo.tkac...@arm.com> * gcc.target/aarch64/store-pair-1.c: Update scan-assembler to check Index: testsuite/g++.dg/torture/pr64282.C =================================================================== --- testsuite/g++.dg/torture/pr64282.C (revision 0) +++ testsuite/g++.dg/torture/pr64282.C (revision 0) @@ -0,0 +1,101 @@ +// { dg-do compile } +template <class _T1> struct A +{ + _T1 first; +}; +struct B +{ + int operator!=(B); +}; +template <typename _Tp> struct C +{ + C (B); + _Tp operator*(); + int operator!=(C); +}; +template <typename _Tp> class D +{ +public: + typedef C<_Tp> const_iterator; + const_iterator m_fn1 () const; + B m_fn2 (); + void m_fn3 (); +}; +class F +{ + struct G + { + static G & + m_fn5 () + { + void fn1 (); + return *reinterpret_cast<G *> (fn1); + } + int * + m_fn6 () + { + return reinterpret_cast<int *> (this); + } + }; + struct _Alloc_hider + { + _Alloc_hider (int *p1, int) : _M_p (p1) {} + int *_M_p; + } _M_dataplus; + G & + m_fn4 () + { + return G::m_fn5 (); + } +public: + F () : _M_dataplus (m_fn4 ().m_fn6 (), 0) {} +}; +class H +{ + void m_fn7 (const F &, bool &); + bool m_fn8 (const D<F> &, const F &, F &); +}; +typedef A<int> CandPair; +class I +{ +public: + virtual void m_fn9 (const F &, bool, D<CandPair> &); +}; +class J : I +{ +public: + void m_fn9 (const F &, bool, D<CandPair> &); +}; +D<I *> c; +void +J::m_fn9 (const F &, bool, D<CandPair> &) +{ + D<int> a; + for (B b; b != a.m_fn2 ();) + ; +} +inline void +fn2 (F p1, int, int, J *p4, D<CandPair>) +{ + D<CandPair> d; + d.m_fn3 (); + p4->m_fn9 (p1, 0, d); + for (D<I *>::const_iterator e = c.m_fn1 (); e != c.m_fn2 ();) + (*e)->m_fn9 (p1, 0, d); +} +void +H::m_fn7 (const F &, bool &) +{ + A<F> f; + D<F> g; + F h; + m_fn8 (g, f.first, h); +} +bool +H::m_fn8 (const D<F> &p1, const F &, F &) +{ + F i; + p1.m_fn1 (); + D<CandPair> j; + fn2 (i, 0, 0, 0, j); +} Index: gimple-fold.c =================================================================== --- gimple-fold.c (revision 220142) +++ gimple-fold.c (working copy) @@ -5649,7 +5649,6 @@ gimple_get_virt_method_for_vtable (HOST_ if (TREE_CODE (v) != VAR_DECL || !DECL_VIRTUAL_P (v)) { - gcc_assert (in_lto_p); /* Pass down that we lost track of the target. */ if (can_refer) *can_refer = false;