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

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

Open
hubert-reinterpretcast opened this issue Dec 23, 2024 · 3 comments
Labels
c++20 clang:frontend Language frontend issues, e.g. anything involving "Sema" concepts C++20 concepts diverges-from:edg Does the clang frontend diverge from edg compiler diverges-from:msvc Does the clang frontend diverge from msvc on this issue

Comments

@hubert-reinterpretcast
Copy link
Collaborator

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
@hubert-reinterpretcast hubert-reinterpretcast added bug Indicates an unexpected problem or unintended behavior c++20 clang:frontend Language frontend issues, e.g. anything involving "Sema" concepts C++20 concepts diverges-from:edg Does the clang frontend diverge from edg compiler diverges-from:msvc Does the clang frontend diverge from msvc on this issue labels Dec 23, 2024
@llvmbot
Copy link
Member

llvmbot commented Dec 23, 2024

@llvm/issue-subscribers-c-20

Author: Hubert Tong (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 (&lt;stdin&gt;)

template &lt;typename T&gt;
concept C = false;

template &lt;typename&gt; struct Q;

template &lt;template &lt;C&gt; class TT&gt;
struct A {
  TT&lt;int&gt; *p; 
};

A&lt;Q&gt; 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

@llvmbot
Copy link
Member

llvmbot commented Dec 23, 2024

@llvm/issue-subscribers-clang-frontend

Author: Hubert Tong (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 (&lt;stdin&gt;)

template &lt;typename T&gt;
concept C = false;

template &lt;typename&gt; struct Q;

template &lt;template &lt;C&gt; class TT&gt;
struct A {
  TT&lt;int&gt; *p; 
};

A&lt;Q&gt; 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

@llvmbot
Copy link
Member

llvmbot commented Dec 23, 2024

@llvm/issue-subscribers-bug

Author: Hubert Tong (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 (&lt;stdin&gt;)

template &lt;typename T&gt;
concept C = false;

template &lt;typename&gt; struct Q;

template &lt;template &lt;C&gt; class TT&gt;
struct A {
  TT&lt;int&gt; *p; 
};

A&lt;Q&gt; 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

@EugeneZelenko EugeneZelenko removed the bug Indicates an unexpected problem or unintended behavior label Dec 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++20 clang:frontend Language frontend issues, e.g. anything involving "Sema" concepts C++20 concepts diverges-from:edg Does the clang frontend diverge from edg compiler diverges-from:msvc Does the clang frontend diverge from msvc on this issue
Projects
None yet
Development

No branches or pull requests

3 participants