https://bugs.llvm.org/show_bug.cgi?id=38431

            Bug ID: 38431
           Summary: "too many template arguments for class template"
                    disallows sensible empty-parameter-pack instantiation
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected]

If I compile this:


template <typename> struct X {};
template <typename... Ts> void   f ( X<int, Ts...>    ) {}
template <typename... Ts> struct A { X<int, Ts...> x; };

int main() {
    f<>  ( X<int>{} );
    A<> a{ X<int>{} };
}


...(with no additional command line flags) I get:


a.cpp:2:38: error: too many template arguments for class template 'X'
template <typename... Ts> void   f ( X<int, Ts...>    ) {}
                                     ^      ~~~~~~
a.cpp:1:28: note: template is declared here
template <typename> struct X {};
~~~~~~~~~~~~~~~~~~~        ^
a.cpp:3:38: error: too many template arguments for class template 'X'
template <typename... Ts> struct A { X<int, Ts...> x; };
                                     ^      ~~~~~~
a.cpp:1:28: note: template is declared here
template <typename> struct X {};
~~~~~~~~~~~~~~~~~~~        ^
a.cpp:6:5: error: no matching function for call to 'f'
    f<>  ( X<int>{} );
    ^~~
3 errors generated.


...but I'm guessing (and GCC 8.2 and GCC trunk apparently agree) that this code
is valid because f() and A can be reasonably instantiated with an empty
parameter pack, as illustrated in main(). I think the error should only come at
the point of any instantiation that actually instantiates X with too many
template arguments.

Godbolt indicates that this happens on 6.0.0 and trunk (338661).

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
[email protected]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to