summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/template/const1.C
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/g++.dg/template/const1.C')
-rw-r--r--gcc/testsuite/g++.dg/template/const1.C30
1 files changed, 30 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.dg/template/const1.C b/gcc/testsuite/g++.dg/template/const1.C
new file mode 100644
index 000000000..629c4d4a9
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/const1.C
@@ -0,0 +1,30 @@
+// PR c++/28385
+// instantiating op() with void()() was making the compiler think that 'fcn'
+// was const, so it could eliminate the call.
+
+// { dg-do run }
+
+extern "C" void abort (void);
+
+int barcnt = 0;
+
+class Foo {
+ public:
+ template<typename T>
+ void operator()(const T& fcn) {
+ fcn();
+ }
+};
+
+void bar() {
+ barcnt++;
+}
+
+int main() {
+ Foo myFoo;
+ myFoo(bar);
+ myFoo(&bar);
+ if (barcnt != 2)
+ abort ();
+ return 0;
+}