PR c++/86728 - C variadic generic lambda.
[official-gcc.git] / gcc / testsuite / g++.dg / template / const1.C
blob629c4d4a916ea1016572fd4123a2f140d148954a
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.
5 // { dg-do run }
7 extern "C" void abort (void);
9 int barcnt = 0;
11 class Foo {
12   public:
13     template<typename T>
14     void operator()(const T& fcn) {
15       fcn();
16     }
19 void bar() {
20   barcnt++;
23 int main() {
24   Foo myFoo;
25   myFoo(bar);
26   myFoo(&bar);
27   if (barcnt != 2)
28     abort ();
29   return 0;