Skip to content

Function with two template template parameters is being ignored #59756

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
bbastin opened this issue Dec 31, 2022 · 2 comments
Closed

Function with two template template parameters is being ignored #59756

bbastin opened this issue Dec 31, 2022 · 2 comments
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema"

Comments

@bbastin
Copy link

bbastin commented Dec 31, 2022

When creating a function template that takes two template template parameters as well as a template parameter pack, Clang states that the template does not fit. This behaviour is inconsistent with the behaviour of both GCC and MSVC, both of which correctly select the template. I could not find anything in the standard that would prohibit using two template template parameters in a function template.

Example:

#include <tuple>
#include <vector>

template <template <typename...> typename Tuple, typename... Targs>
auto unmarshal() {
    Tuple<Targs...> ret;
    return ret;
}

template <template <typename> typename Array,
          template <typename...> typename Tuple, typename... Targs>
auto unmarshal() {
    Array<Tuple<Targs...>> ret;
    return ret;
}

int main() {
    [[maybe_unused]] auto fields1 = unmarshal<std::tuple, unsigned, int>();
    [[maybe_unused]] auto fields2 = unmarshal<std::vector, std::tuple, unsigned, int>();
}

Error using clang trunk:

<source>:19:37: error: no matching function for call to 'unmarshal'
    [[maybe_unused]] auto fields2 = unmarshal<std::vector, std::tuple, unsigned, int>();
                                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<source>:5:6: note: candidate template ignored: invalid explicitly-specified argument for template parameter 'Targs'
auto unmarshal() {
     ^
<source>:12:6: note: candidate template ignored: invalid explicitly-specified argument for template parameter 'Array'
auto unmarshal() {
     ^
1 error generated.

Example in Compiler Explorer: https://godbolt.org/z/ME6qx5jWE

The same error occurs on my local machine running Clang 14.0.6.

@EugeneZelenko EugeneZelenko added clang:frontend Language frontend issues, e.g. anything involving "Sema" and removed new issue labels Dec 31, 2022
@llvmbot
Copy link
Member

llvmbot commented Dec 31, 2022

@llvm/issue-subscribers-clang-frontend

@mizvekov
Copy link
Contributor

mizvekov commented Feb 6, 2025

This always required P0522 in order to work, which up until clang-18 required the command line flag '-frelaxed-template-template-args'.
Since clang-19, the default has changed.

Duplicate of #95732

@mizvekov mizvekov closed this as completed Feb 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema"
Projects
None yet
Development

No branches or pull requests

4 participants