| 1 |
// ICE in explicit instantiation of a function with contracts |
| 2 |
// { dg-do run } |
| 3 |
// { dg-options "-std=c++20 -fcontracts -fcontract-continuation-mode=on" } |
| 4 |
|
| 5 |
template<class T> |
| 6 |
void foo(T t) |
| 7 |
[[pre : t == 9 ]] { |
| 8 |
} |
| 9 |
|
| 10 |
template void foo<int>(int i); |
| 11 |
|
| 12 |
|
| 13 |
template<class T> |
| 14 |
struct templateS |
| 15 |
{ |
| 16 |
void fooS(T t) |
| 17 |
[[pre : t == 9 ]] { |
| 18 |
} |
| 19 |
}; |
| 20 |
|
| 21 |
template struct templateS<int>; |
| 22 |
|
| 23 |
|
| 24 |
struct S { |
| 25 |
|
| 26 |
template<class T> |
| 27 |
void fooS(T t) |
| 28 |
[[pre : t == 9 ]] { |
| 29 |
} |
| 30 |
|
| 31 |
template<class T> |
| 32 |
static void fooStatic(T t) |
| 33 |
[[pre : t == 9 ]] { |
| 34 |
} |
| 35 |
}; |
| 36 |
|
| 37 |
template void S::fooS<int>(int i); |
| 38 |
|
| 39 |
template void S::fooStatic<int>(int i); |
| 40 |
|
| 41 |
int main() |
| 42 |
{ |
| 43 |
foo(3); |
| 44 |
|
| 45 |
templateS<int> ts; |
| 46 |
ts.fooS(3); |
| 47 |
|
| 48 |
S s; |
| 49 |
s.fooS(3); |
| 50 |
S::fooStatic(3); |
| 51 |
} |
| 52 |
|
| 53 |
// { dg-output "contract violation in function foo<int> at .* t == 9.*(\n|\r\n|\r)" } |
| 54 |
// { dg-output "contract violation in function templateS<int>::fooS at .* t == 9.*(\n|\r\n|\r)" } |
| 55 |
// { dg-output "contract violation in function S::fooS<int> at .* t == 9.*(\n|\r\n|\r)" } |
| 56 |
// { dg-output "contract violation in function S::fooStatic<int> at .* t == 9.*(\n|\r\n|\r)" } |