1 // RUN: %clang_cc1 -std=c++98 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors 2 // RUN: %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors 3 // expected-no-diagnostics 4 5 namespace dr408 { // dr408: 3.4 6 template<int N> void g() { int arr[N != 1 ? 1 : -1]; } 7 template<> void g<2>() { } 8 9 template<typename T> struct S { 10 static int i[]; 11 void f(); 12 }; 13 template<typename T> int S<T>::i[] = { 1 }; 14 15 template<typename T> void S<T>::f() { 16 g<sizeof (i) / sizeof (int)>(); 17 } 18 template<> int S<int>::i[] = { 1, 2 }; 19 template void S<int>::f(); // uses g<2>(), not g<1>(). 20 21 22 template<typename T> struct R { 23 static int arr[]; 24 void f(); 25 }; 26 template<typename T> int R<T>::arr[1]; 27 template<typename T> void R<T>::f() { 28 int arr[sizeof(arr) != sizeof(int) ? 1 : -1]; 29 } 30 template<> int R<int>::arr[2]; 31 template void R<int>::f(); 32 } 33