[llvm-bugs] [Bug 38431] New: "too many template arguments for class template" disallows sensible empty-parameter-pack instantiation

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Aug 2 12:05:19 PDT 2018


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: unassignedclangbugs at nondot.org
          Reporter: tonyelewis at hotmail.com
                CC: dgregor at apple.com, llvm-bugs at lists.llvm.org

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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20180802/5d29b36b/attachment.html>


More information about the llvm-bugs mailing list