Issue 90177
Summary CTAD: incorrect transformed require-clause for the alias deduction guide
Labels clang, c++20, clang:frontend
Assignees
Reporter hokein
    Example:

```
struct Key1  {};

template <class Key>
struct Foo {
 Foo(Key);
};

template <class D>
constexpr bool C = sizeof(D);

template <class Key>
  requires (C<Key>)
Foo(Key) -> Foo<Key>;

template <class T>
struct HasTemplateParam {
 template <class Key>
  using Alias = Foo<Key>;
};

class Forward;
struct Test : HasTemplateParam<Forward> {
  using Foo1 = decltype(Alias{
    Key1(),
  });
};
```

clang rejects the above valid code with the following diagnostics:

```
<source>:9:20: error: invalid application of 'sizeof' to an incomplete type 'Forward'
 9 | constexpr bool C = sizeof(D);
      | ^~~~~~~~~
<source>:12:13: note: in instantiation of variable template specialization 'C<Forward>' requested here
   12 |   requires (C<Key>)
 |             ^
<source>:12:13: note: while substituting template arguments into constraint _expression_ here
   12 |   requires (C<Key>)
 |             ^~~~~~
<source>:23:25: note: while checking constraint satisfaction for template '<deduction guide for Alias><Forward>' required here
   23 |   using Foo1 = decltype(Alias{
      | ^~~~~
<source>:23:25: note: in instantiation of function template specialization 'HasTemplateParam<Forward>::<deduction guide for Alias><Key1>' requested here
<source>:21:7: note: forward declaration of 'Forward'
 21 | class Forward;
```

It seems to be an issue in the transformed require-clause for the alias deduction guide. The require _expression_ should be evaluated on  the type `Key1`, rather than the outer type `Forward`.

_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to