Skip to content

Constraints of template template parameter not checked for non-dependent arguments despite [temp.names]/8 #121008

Open
@hubert-reinterpretcast

Description

@hubert-reinterpretcast

https://wg21.link/temp.names#8 specifies that when

all template-arguments in the simple-template-id are non-dependent ([temp.dep.temp]), the associated constraints ([temp.constr.decl]) of the constrained template shall be satisfied

where the "constrained template" may be a template template parameter.

Even when template is instantiated, GCC and Clang both fail to emit a diagnostic for a violation of this rule.
EDG and MSVC both diagnose without needing an instantiation.

See also: cplusplus/CWG#658

Online compiler link: https://godbolt.org/z/fTzMnEPG8

SOURCE (<stdin>)

template <typename T>
concept C = false;

template <typename> struct Q;

template <template <C> class TT>
struct A {
  TT<int> *p; 
};

A<Q> a;

COMPILER INVOCATION

clang++ -fsyntax-only -std=c++20 -Wall -Wextra -Werror -pedantic-errors -xc++ -

ACTUAL COMPILER OUTPUT

(clean compile)

EXPECTED COMPILER OUTPUT

(error)

COMPILER VERSION INFO (clang++ -v)

clang version 20.0.0git (https://github.com/llvm/llvm-project.git b84218526d364cb9fda23bfca164d25a7b03a641)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /opt/wandbox/clang-head/bin
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/13
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/14
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/14
Candidate multilib: .;@m64
Selected multilib: .;@m64

Metadata

Metadata

Assignees

No one assigned

    Labels

    c++20clang:frontendLanguage frontend issues, e.g. anything involving "Sema"conceptsC++20 conceptsdiverges-from:edgDoes the clang frontend diverge from edg compilerdiverges-from:msvcDoes the clang frontend diverge from msvc on this issue

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions