Issue 178860
Summary Static variable template with deduced type within a class template is rejected
Labels clang:frontend, confirmed, diverges-from:gcc, diverges-from:msvc, diverges-from:edg
Assignees
Reporter Endilll
    Consider the following example:
```cpp
template <typename>
struct A {
    template <typename>
    static constexpr auto value = 5; 
};

decltype(A<void>::value<void>) x{};
```
Clang has been rejecting this since 9 (https://godbolt.org/z/8xMYEW51a), but other compilers accept (https://godbolt.org/z/Wcnz4K8f6):
```
<source>:13:37: error: illegal initializer type 'decltype(A<void>::value<void>)' (aka 'const auto')
   13 | decltype(A<void>::value<void>) x{};
      | ^
```

Consider the following example derived from the first one that adds a type alias:
```cpp
template <typename>
struct A {
 template <typename>
    static constexpr auto value = 5; 

    using result_t = decltype(value<void>);
};

decltype(A<void>::value<void>) x{};
```
Clang has been rejecting this since 12 with the same diagnostic as above (https://godbolt.org/z/zqaExM1a8), but other compiler accept (https://godbolt.org/z/zxx1acje6). Since 21 we issue a different diagnostic:
```
<source>:9:19: error: the type of variable template specialization 'value<void>' declared with deduced type 'const auto' depends on itself
    9 | decltype(A<void>::value<void>) x{};
      | ^
```

Related: #147992, #134526, #45408
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to