Skip to content
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

substitution failure for template argument pack in template argument #71811

Closed
rroohhh opened this issue Nov 9, 2023 · 3 comments
Closed

substitution failure for template argument pack in template argument #71811

rroohhh opened this issue Nov 9, 2023 · 3 comments
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema" duplicate Resolved as duplicate

Comments

@rroohhh
Copy link

rroohhh commented Nov 9, 2023

The following code

#include <utility>
#include <variant>
#include <vector>

template <class T>
class Wrap {};


template <
    template <typename>
    class Prefix,
    template <typename>
    typename OuterType,
    typename... InnerTypes>
auto prefix_inner_types_helper(OuterType<InnerTypes...> v) -> OuterType<Prefix<InnerTypes>...>;


using ReadResult = std::variant<std::monostate, std::vector<int>>;

using PromiseType =
    decltype(prefix_inner_types_helper<Wrap>(std::declval<ReadResult>()));

gives the following error:

<source>:21:14: error: no matching function for call to 'prefix_inner_types_helper'
   21 |     decltype(prefix_inner_types_helper<Wrap>(std::declval<ReadResult>()));
      |              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<source>:15:6: note: candidate template ignored: substitution failure [with Prefix = Wrap]: template template argument has different template parameters than its corresponding template template parameter
   21 | auto prefix_inner_types_helper(OuterType<InnerTypes...> v) -> OuterType<Prefix<InnerTypes>...>;
      |      ^
   22 | 
   23 | 
   24 | using ReadResult = std::variant<std::monostate, std::vector<int>>;
   25 | 
   26 | using PromiseType =
   27 |     decltype(prefix_inner_types_helper<Wrap>(std::declval<ReadResult>()));
      |              ~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
Compiler returned: 1

while gcc accepts it without any complaints.
(See https://godbolt.org/z/7qoWsWe4a)

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

llvmbot commented Nov 9, 2023

@llvm/issue-subscribers-clang-frontend

Author: Robin Heinemann (rroohhh)

The following code ```cpp #include <utility> #include <variant> #include <vector>

template <class T>
class Wrap {};

template <
template <typename>
class Prefix,
template <typename>
typename OuterType,
typename... InnerTypes>
auto prefix_inner_types_helper(OuterType<InnerTypes...> v) -> OuterType<Prefix<InnerTypes>...>;

using ReadResult = std::variant<std::monostate, std::vector<int>>;

using PromiseType =
decltype(prefix_inner_types_helper<Wrap>(std::declval<ReadResult>()));

gives the following error:

<source>:21:14: error: no matching function for call to 'prefix_inner_types_helper'
21 | decltype(prefix_inner_types_helper<Wrap>(std::declval<ReadResult>()));
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<source>:15:6: note: candidate template ignored: substitution failure [with Prefix = Wrap]: template template argument has different template parameters than its corresponding template template parameter
21 | auto prefix_inner_types_helper(OuterType<InnerTypes...> v) -> OuterType<Prefix<InnerTypes>...>;
| ^
22 |
23 |
24 | using ReadResult = std::variant<std::monostate, std::vector<int>>;
25 |
26 | using PromiseType =
27 | decltype(prefix_inner_types_helper<Wrap>(std::declval<ReadResult>()));
| ~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
Compiler returned: 1

while `gcc` accepts it without any complaints.
(See https://godbolt.org/z/7qoWsWe4a)
</details>

@shafik
Copy link
Collaborator

shafik commented Nov 16, 2023

This is fixed using -frelaxed-template-template-args: https://godbolt.org/z/rPGa1TEn7

We tried turning this on by default: https://discourse.llvm.org/t/why-frelaxed-template-template-args-is-added-back/65727 but a cuda thrust seems to have an issue: https://reviews.llvm.org/D109496

I don't know if and when this will be picked up again.

CC @mizvekov @cor3ntin @AaronBallman

@mizvekov
Copy link
Contributor

Duplicate of #55894

@mizvekov mizvekov marked this as a duplicate of #55894 Apr 27, 2024
@mizvekov mizvekov closed this as not planned Won't fix, can't repro, duplicate, stale Apr 27, 2024
@EugeneZelenko EugeneZelenko added the duplicate Resolved as duplicate label Apr 27, 2024
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" duplicate Resolved as duplicate
Projects
None yet
Development

No branches or pull requests

5 participants