Skip to content

Clang rejects valid program involving parameter packs with in between type #78449

@ranaanoop

Description

@ranaanoop

The following program is rejected by clang while both gcc and msvc accepts this. Demo

#include <type_traits>

template <typename... T>
struct args_tag
{
    using type = std::common_type_t<T...>;
};

template <typename... T>
void bar(args_tag<T...>, std::type_identity_t<T>..., int, std::type_identity_t<T>...) {}


// example
int main() {
    bar(args_tag<int, int>{}, 4, 8, 15, 16, 23);
   
}

Clang says:

<source>:15:5: error: no matching function for call to 'bar'
   15 |     bar(args_tag<int, int>{}, 4, 8, 15, 16, 23);
      |     ^~~
<source>:10:6: note: candidate template ignored: deduced packs of different lengths for parameter 'T' (<int, int> vs. <>)
   10 | void bar(args_tag<T...>, std::type_identity_t<T>..., int, std::type_identity_t<T>...) {}
      |      ^

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:frontendLanguage frontend issues, e.g. anything involving "Sema"rejects-valid

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions