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