[clang] Add tests for CWG issues 6, 212, 232, 2823. (PR #165633)

Vlad Serebrennikov via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 30 02:34:05 PDT 2025


================
@@ -230,6 +230,37 @@ namespace cwg211 { // cwg211: 2.7
   };
 } // namespace cwg211
 
+namespace cwg212 { // cwg212: yes
+  template<typename T> struct Base;
+  template<typename T> struct Derived;
+
+  int *overload(void*);
+  float *overload(Base<int>*);
+  double *overload(Base<long>*);
+
+  void f(Derived<int> *p) {
+    // OK, calls void* overload.
+    int *a = overload(p);
+
+    Base<int> *q = p; // expected-error {{cannot initialize}}
----------------
Endilll wrote:

```suggestion
    Base<int> *q = p;
    // expected-error at -1 {{cannot initialize a variable of type 'Base<int> *' with an lvalue of type 'Derived<int> *'}}
```

https://github.com/llvm/llvm-project/pull/165633


More information about the cfe-commits mailing list