https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116106
Bug ID: 116106
Summary: Unused concept template arguments not checked
Product: gcc
Version: 15.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: jakub at gcc dot gnu.org
CC: daniel.kruegler at googlemail dot com, jason at gcc dot
gnu.org,
ppalka at gcc dot gnu.org, unassigned at gcc dot gnu.org,
webrown.cpp at gmail dot com
Depends on: 115746
Blocks: 110338
Target Milestone: ---
+++ This bug was initially created as a clone of Bug #115746 +++
template <class T> concept C = true;
template <class T> requires (C<typename T::type>)
constexpr bool foo () { return true; };
static_assert (foo <int> ());
is incorrectly accepted by GCC with -std=c++20 or higher, while clang rejects
that.
Similarly
template <class T> concept A = true;
template <class T> concept B = B<T> && true;
template <class T> requires (B<typename T::type>)
constexpr bool bar () { return true; };
static_assert (bar <int> ());
Jonathan mentions http://eel.is/c++draft/temp.constr.atomic#3.sentence-2
I bet this is because we see the concepts not actually using any template
arguments (or at least not using the argument to which typename T::type is
passed if it was modified to depend on another template parameter), so create a
NULL mapping (or one where T is not mentioned) and then when using the concept
don't add that mapping even when unused.
I guess it doesn't have to be added in the trivial and most common case where
just some other template parameter is passed to the concept, but if it is
something more complex like in this case it probably needs to be added.
Referenced Bugs:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110338
[Bug 110338] Implement C++26 language features
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115746
[Bug 115746] [C++26] P2963R3 - Ordering of constraints involving fold
expressions