Mercurial > hg > CbC > CbC_gcc
annotate gcc/testsuite/g++.dg/template/const1.C @ 131:84e7813d76e9
gcc-8.2
author | mir3636 |
---|---|
date | Thu, 25 Oct 2018 07:37:49 +0900 |
parents | 04ced10e8804 |
children |
rev | line source |
---|---|
111 | 1 // PR c++/28385 |
2 // instantiating op() with void()() was making the compiler think that 'fcn' | |
3 // was const, so it could eliminate the call. | |
4 | |
5 // { dg-do run } | |
6 | |
7 extern "C" void abort (void); | |
8 | |
9 int barcnt = 0; | |
10 | |
11 class Foo { | |
12 public: | |
13 template<typename T> | |
14 void operator()(const T& fcn) { | |
15 fcn(); | |
16 } | |
17 }; | |
18 | |
19 void bar() { | |
20 barcnt++; | |
21 } | |
22 | |
23 int main() { | |
24 Foo myFoo; | |
25 myFoo(bar); | |
26 myFoo(&bar); | |
27 if (barcnt != 2) | |
28 abort (); | |
29 return 0; | |
30 } |