llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

[Clang] Variable template partial specialization cannot specialize primary template with `auto` NTTP

Open MagentaTreehouse opened this issue 2 years ago • 3 comments

Reproducer:

template <auto> constexpr bool b = false;
template <int I> constexpr bool b<I> = true; 

Error:

<source>:2:33: error: variable template partial specialization does not specialize any template argument; to define the primary template, remove the template argument list
    2 | template <int I> constexpr bool b<I> = true;
      |                                 ^~~~

Possibly related: #42421.

See Compiler Explorer: https://godbolt.org/z/nEdbcKqWs

MagentaTreehouse avatar Dec 01 '24 02:12 MagentaTreehouse

@llvm/issue-subscribers-clang-frontend

Author: None (MagentaTreehouse)

Reproducer: ```c++ template <auto> constexpr bool b = false; template <int I> constexpr bool b<I> = true; ```

Error:

&lt;source&gt;:2:33: error: variable template partial specialization does not specialize any template argument; to define the primary template, remove the template argument list
    2 | template &lt;int I&gt; constexpr bool b&lt;I&gt; = true;
      |                                 ^~~~

Possibly related: #42421.

See Compiler Explorer: https://godbolt.org/z/nEdbcKqWs

llvmbot avatar Dec 01 '24 03:12 llvmbot

edg also agrees w/ gcc/MSVS: https://godbolt.org/z/MqE54KnfM

shafik avatar Dec 02 '24 22:12 shafik

This is a bug. The equivalent class template partial specialization case does work with Clang.

hubert-reinterpretcast avatar Dec 20 '24 17:12 hubert-reinterpretcast