1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -emit-llvm-only -O1 %s 2*f4a2713aSLionel Sambuc // This used to crash under asan and valgrind. 3*f4a2713aSLionel Sambuc // PR12284 4*f4a2713aSLionel Sambuc 5*f4a2713aSLionel Sambuc template < typename _Tp > struct new_allocator 6*f4a2713aSLionel Sambuc { 7*f4a2713aSLionel Sambuc typedef _Tp *pointer; 8*f4a2713aSLionel Sambuc template < typename > struct rebind { 9*f4a2713aSLionel Sambuc typedef new_allocator other; 10*f4a2713aSLionel Sambuc }; 11*f4a2713aSLionel Sambuc }; 12*f4a2713aSLionel Sambuc template < typename _Tp > struct allocator:new_allocator < _Tp > { 13*f4a2713aSLionel Sambuc }; 14*f4a2713aSLionel Sambuc template < typename _Tp, typename _Alloc > struct _Vector_base { 15*f4a2713aSLionel Sambuc typedef typename _Alloc::template rebind < _Tp >::other _Tp_alloc_type; 16*f4a2713aSLionel Sambuc struct _Vector_impl { 17*f4a2713aSLionel Sambuc typename _Tp_alloc_type::pointer _M_end_of_storage; 18*f4a2713aSLionel Sambuc }; 19*f4a2713aSLionel Sambuc _Vector_base () { 20*f4a2713aSLionel Sambuc foo((int *) this->_M_impl._M_end_of_storage); 21*f4a2713aSLionel Sambuc } 22*f4a2713aSLionel Sambuc void foo(int *); 23*f4a2713aSLionel Sambuc _Vector_impl _M_impl; 24*f4a2713aSLionel Sambuc }; 25*f4a2713aSLionel Sambuc template < typename _Tp, typename _Alloc = 26*f4a2713aSLionel Sambuc allocator < _Tp > >struct vector:_Vector_base < _Tp, _Alloc > { }; 27*f4a2713aSLionel Sambuc 28*f4a2713aSLionel Sambuc 29*f4a2713aSLionel Sambuc template < class T> struct HHH {}; 30*f4a2713aSLionel Sambuc struct DDD { int x_;}; 31*f4a2713aSLionel Sambuc struct Data; 32*f4a2713aSLionel Sambuc struct X1; 33*f4a2713aSLionel Sambuc struct CCC:DDD { virtual void xxx (HHH < X1 >); }; 34*f4a2713aSLionel Sambuc template < class SSS > struct EEE:vector < HHH < SSS > > { }; 35*f4a2713aSLionel Sambuc template < class SSS, class = EEE < SSS > >class FFF { }; 36*f4a2713aSLionel Sambuc template < class SSS, class GGG = EEE < SSS > >class AAA:FFF <GGG> { }; 37*f4a2713aSLionel Sambuc class BBB:virtual CCC { 38*f4a2713aSLionel Sambuc void xxx (HHH < X1 >); 39*f4a2713aSLionel Sambuc vector < HHH < X1 > >aaa; 40*f4a2713aSLionel Sambuc }; 41*f4a2713aSLionel Sambuc class ZZZ:AAA < Data >, BBB { virtual ZZZ *ppp () ; }; 42*f4a2713aSLionel Sambuc ZZZ * ZZZ::ppp () { return new ZZZ; } 43