44 lines · cpp
1// RUN: %clang_cc1 -std=c++11 %s -emit-pch -o %t.pch2// RUN: %clang_cc1 -fsyntax-only -std=c++11 %s -include-pch %t.pch -verify3 4// RUN: %clang_cc1 -std=c++11 %s -emit-pch -fpch-instantiate-templates -o %t.pch5// RUN: %clang_cc1 -fsyntax-only -std=c++11 %s -include-pch %t.pch -verify6 7// expected-no-diagnostics8 9// This reduced test case exposed a use-after-free memory bug, which was reliable10// reproduced only on guarded malloc (and probably valgrind).11 12#ifndef HEADER13#define HEADER14 15template < class _T2> struct is_convertible;16template <> struct is_convertible<int> { typedef int type; };17 18template <class _T1, class _T2> struct pair {19 typedef _T1 first_type;20 typedef _T2 second_type;21 template <class _U1, class _U2, class = typename is_convertible< first_type>::type>22 pair(_U1&& , _U2&& ); // expected-note {{candidate}}23};24 25template <class _ForwardIterator>26pair<_ForwardIterator, _ForwardIterator> __equal_range(_ForwardIterator) {27 return pair<_ForwardIterator, _ForwardIterator>(0, 0); // expected-error {{no matching constructor}}28}29 30template <class _ForwardIterator>31pair<_ForwardIterator, _ForwardIterator> equal_range( _ForwardIterator a) {32 return __equal_range(a); // expected-note {{instantiation}}33}34 35class A {36 pair<int, int> range() {37 return equal_range(0); // expected-note {{instantiation}}38 }39};40 41#else42 43#endif44