summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/template/conv19.C
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/g++.dg/template/conv19.C')
-rw-r--r--gcc/testsuite/g++.dg/template/conv19.C34
1 files changed, 34 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.dg/template/conv19.C b/gcc/testsuite/g++.dg/template/conv19.C
new file mode 100644
index 00000000000..7a3da939c1f
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/conv19.C
@@ -0,0 +1,34 @@
+// PR c++/101698
+// { dg-do compile { target c++11 } }
+
+class Base {
+ public:
+ template <class T>
+ operator const T&() const = delete;
+
+ virtual operator const int&() const {
+ static int res;
+ return res;
+ }
+};
+
+template <class T>
+class Derive : public Base {
+ public:
+ operator const T&() const override {
+ using Y = int;
+ //static_assert(__is_same_as(T,Y), "");
+
+ static int res;
+
+ res = Base::operator const Y&(); // OK
+ res = Base::operator const T&(); // { dg-bogus "deleted" }
+ return res;
+ }
+};
+
+int main() {
+ Derive<int> a;
+ const int& b = a;
+ (void)b;
+}