[clang] [Clang] Implement CWG2517 Useless restriction on use of parameter in constraint-expression (PR #132919)

Imad Aldij via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 25 08:18:22 PDT 2025


================
@@ -98,13 +98,6 @@ namespace std_example {
   using c1c2 = C_check<int *>; // expected-error{{constraints not satisfied for class template 'C_check' [with T = int *]}}
 }
 
-// typeid() of an expression becomes potentially evaluated if the expression is
-// of a polymorphic type.
-class X { virtual ~X(); };
-constexpr bool b = requires (X &x) { static_cast<int(*)[(typeid(x), 0)]>(nullptr); };
-// expected-error at -1{{constraint variable 'x' cannot be used in an evaluated context}}
-// expected-note at -2{{'x' declared here}}
-
----------------
imdj wrote:

Here similarly we get:
```
error: 'expected-warning' diagnostics seen but not expected: 
  File [...]/simple-requirement.cpp Line 104: left operand of comma operator has no effect
  File [...]/simple-requirement.cpp Line 104: variable length arrays in C++ are a Clang extension
error: 'expected-note' diagnostics seen but not expected: 
  File [...]/simple-requirement.cpp Line 104: function parameter 'x' with unknown value cannot be used in a constant expression
  File [...]/simple-requirement.cpp Line 104: declared here
```

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


More information about the cfe-commits mailing list