https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120836
Bug ID: 120836
Summary: [16 regression] Including <concepts> hides
'satisfaction value ... changed' diagnostic
Product: gcc
Version: 16.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: m.cencora at gmail dot com
Target Milestone: ---
Given code below:
#include <concepts>
template <typename T>
concept printable = requires (const T& a) { a.print(); };
struct foo
{
static constexpr bool member1 = printable<foo>;
bool member2 = printable<foo>;
void print() const
{
}
static constexpr bool member3 = printable<foo>;
};
int main()
{
static_assert(!foo::member1);
static_assert(foo{}.member2);
static_assert(foo::member3);
static_assert(printable<foo>);
}
When compiled on gcc-16 with -std=c++23 just prints:
<source>: In function 'int main()':
<source>:23:24: error: static assertion failed
23 | static_assert(foo::member3);
| ~~~~~^~~~~~~
Compiler returned: 1
If I use -std=c++20 or compile with gcc-15 or remove '#include <concepts>' I
get much better diagnostics:
<source>: In function 'int main()':
<source>:22:25: error: static assertion failed
22 | static_assert(foo{}.member2);
| ~~~~~~^~~~~~~
<source>:23:24: error: static assertion failed
23 | static_assert(foo::member3);
| ~~~~~^~~~~~~
<source>:24:19: error: static assertion failed
24 | static_assert(printable<foo>);
| ^~~~~~~~~~~~~~
<source>:24:19: note: constraints not satisfied
<source>:4:9: required by the constraints of 'template<class T> concept
printable'
<source>:4:21: in requirements with 'const T& a' [with T = foo]
<source>:4:21: error: satisfaction value of atomic constraint 'requires(const
T& a) {a->print();} [with T = foo]' changed from 'false' to 'true'
4 | concept printable = requires (const T& a) { a.print(); };
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<source>:8:37: note: satisfaction value first evaluated to 'false' from here
8 | static constexpr bool member1 = printable<foo>;
| ^~~~~~~~~~~~~~
Compiler returned: 1