Debian Codegraph @

gcc/testsuite/gdc.test/compilable/fail137.d

raw
1 // https://issues.dlang.org/show_bug.cgi?id=751
2 // Compiler segfault on template expansion
3
4 extern(C) int printf(const char*, ...);
5
6 template TypeTuple( TList... )
7 {
8 alias TList TypeTuple;
9 }
10
11 template IndexOf( T, TList... )
12 {
13 static if( TList.length == 0 )
14 const size_t IndexOf = 1;
15 else static if( is( T == typeof( TList[0] ) ) )
16 const size_t IndexOf = 0;
17 else
18 const size_t IndexOf = 1 + IndexOf!( T, (TList[1 .. $]) );
19 }
20
21 void main()
22 {
23 TypeTuple!(int, long) T;
24 printf( "%u\n", cast(uint)IndexOf!(long, T) );
25 }