https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125490
Bug ID: 125490
Summary: GCC accepts an invalid concept that compares sizeof(T)
with nullptr
Product: gcc
Version: 15.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: qurong at ios dot ac.cn
Target Milestone: ---
GCC 15.2.0 accepts the following C++20 program, while Clang 22 rejects it:
template<class T>
concept C1 = sizeof(T) == nullptr;
template<class T>
concept D1 = requires(T t) {
{ t } -> C1;
};
void f(D1 auto) {}
int main() {
f(0);
}
GCC:gcc15 15.2.0
-std=c++20: accepts
-std=c++20 -pedantic-errors: accepts
Clang: clang++-22 22.0.0
-std=c++20: rejects
-std=c++20 -pedantic-errors: rejects
Clang diagnostic:
error: invalid operands to binary expression ('__size_t' (aka 'unsigned long')
and 'std::nullptr_t')