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