Issue 177530
Summary [bug] Template type aliases are not evaluated as original template in deduction
Labels new issue
Assignees
Reporter notgapriel
    Take the below example code. With the flags
`-pedantic -Wextra -Wall -Werror -std=c++17`, this does not compile with `clang++` (latest `main`, `c63a744f3fbc91f0f544d79a50ae91e860d092b7`) but does compile with `g++` (v15.2). This appears to be because the `packer_alias` is not considered equivalent to the class template it aliases or because it is not evaluated/dealiased before deduction for template candidates. The fact that this compiles in GCC without warnings and without using compiler extensions implies that this is a hole in Clang's implementation.

```cpp
#include <tuple> // `std::tuple` used as example class template
#include <iostream>

template <template <typename...> typename Packer_>
struct A {
  // aliased type temploid, equivalent to `Packer_`
  template <typename... Args_>
  using packer_alias = Packer_<Args_...>;
};

template <
  typename T_,
  template <typename...> typename OriginalPacker_
>
struct B;

template <template <typename...> typename OriginalPacker_, typename... Args_>
struct B<OriginalPacker_<Args_...>, OriginalPacker_> {};

int main() {
  (void) typeid(B<std::tuple<int, float>, std::tuple>); // compiles with both clang++ and g++
  (void) typeid(B<std::tuple<int, float>, A<std::tuple>::template packer_alias>); // compiles with only g++

  return 0;
}
```

The error log is:
```
./clang-issue.cpp:26:10: error: implicit instantiation of undefined template 'B<std::tuple<int, float>, A<std::tuple<int, float>>::packer_alias>'
   26 |   (void) typeid(B<std::tuple<int, float>, A<std::tuple<int, float>>::template packer_alias>); // compiles with only g++
      |          ^
./clang-issue.cpp:18:8: note: template is declared here
   18 | struct B;
      |        ^
1 error generated.
```

If someone knows where to find the relevant spec that specifies whether a compiler should treat template aliases as a separate class template or whether they should be evaluated before candidate templates are chosen, feel free to mention in the replies for this issue. Thank you for your attention to this issue.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to