Skip to content

[Clang] Spurious error when template template parameter substituted using a class template with an NTTP whose type is its first template parameter #134519

@ednolan

Description

@ednolan

Given the following code:

template <typename Foo, template <typename, Foo> typename>
class Bar {};

template <typename Foo, Foo>
class Quux : public Bar<Foo, Quux> {};

static_assert(sizeof(Quux<int, 0>));

Clang 20.1.2 and trunk produce the following error:

foo.cpp:4:20: error: conflicting deduction 'type-parameter-0-0' against 'int' for parameter
    4 | template <typename Foo, Foo>
      |                    ^
foo.cpp:5:30: note: template template argument has different template parameters than its corresponding template template parameter
    5 | class Quux : public Bar<Foo, Quux> {};
      |                              ^
foo.cpp:1:58: note: previous template template parameter is here
    1 | template <typename Foo, template <typename, Foo> typename>
      |                         ~~~~~~~~~~~~~~~~~~~~~~~~         ^
foo.cpp:7:15: note: in instantiation of template class 'Quux<int, 0>' requested here
    7 | static_assert(sizeof(Quux<int, 0>));
      |               ^
1 error generated.

Compiler explorer link: https://godbolt.org/z/5Mar9h7zE

The code is accepted by Clang 19, GCC, MSVC, and EDG.

Bisecting shows that this started with 28ad897.

CC @mizvekov

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:frontendLanguage frontend issues, e.g. anything involving "Sema"duplicateResolved as duplicate

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions