1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -std=c++11 %s -emit-pch -o %t.pch
2*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -fsyntax-only -std=c++11 %s -include-pch %t.pch -verify
3*f4a2713aSLionel Sambuc // expected-no-diagnostics
4*f4a2713aSLionel Sambuc
5*f4a2713aSLionel Sambuc // rdar://12631281
6*f4a2713aSLionel Sambuc // This reduced test case exposed a use-after-free memory bug, which was reliable
7*f4a2713aSLionel Sambuc // reproduced only on guarded malloc (and probably valgrind).
8*f4a2713aSLionel Sambuc
9*f4a2713aSLionel Sambuc #ifndef HEADER
10*f4a2713aSLionel Sambuc #define HEADER
11*f4a2713aSLionel Sambuc
12*f4a2713aSLionel Sambuc template < class _T2> struct is_convertible;
13*f4a2713aSLionel Sambuc template <> struct is_convertible<int> { typedef int type; };
14*f4a2713aSLionel Sambuc
15*f4a2713aSLionel Sambuc template <class _T1, class _T2> struct pair {
16*f4a2713aSLionel Sambuc typedef _T1 first_type;
17*f4a2713aSLionel Sambuc typedef _T2 second_type;
18*f4a2713aSLionel Sambuc template <class _U1, class _U2, class = typename is_convertible< first_type>::type>
19*f4a2713aSLionel Sambuc pair(_U1&& , _U2&& ); // expected-note {{candidate}}
20*f4a2713aSLionel Sambuc };
21*f4a2713aSLionel Sambuc
22*f4a2713aSLionel Sambuc template <class _ForwardIterator>
__equal_range(_ForwardIterator)23*f4a2713aSLionel Sambuc pair<_ForwardIterator, _ForwardIterator> __equal_range(_ForwardIterator) {
24*f4a2713aSLionel Sambuc return pair<_ForwardIterator, _ForwardIterator>(0, 0); // expected-error {{no matching constructor}}
25*f4a2713aSLionel Sambuc }
26*f4a2713aSLionel Sambuc
27*f4a2713aSLionel Sambuc template <class _ForwardIterator>
equal_range(_ForwardIterator a)28*f4a2713aSLionel Sambuc pair<_ForwardIterator, _ForwardIterator> equal_range( _ForwardIterator a) {
29*f4a2713aSLionel Sambuc return __equal_range(a); // expected-note {{instantiation}}
30*f4a2713aSLionel Sambuc }
31*f4a2713aSLionel Sambuc
32*f4a2713aSLionel Sambuc class A {
range()33*f4a2713aSLionel Sambuc pair<int, int> range() {
34*f4a2713aSLionel Sambuc return equal_range(0); // expected-note {{instantiation}}
35*f4a2713aSLionel Sambuc }
36*f4a2713aSLionel Sambuc };
37*f4a2713aSLionel Sambuc
38*f4a2713aSLionel Sambuc #else
39*f4a2713aSLionel Sambuc
40*f4a2713aSLionel Sambuc #endif
41