https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125625
Bug ID: 125625
Summary: different errors (or no error at all) when atomic
constrain changes false->true and true->false
Product: gcc
Version: 17.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: nickolay.merkin at gmail dot com
Target Milestone: ---
Same constrain may change its value in different points of a program.
Consider a type D, an overloaded function f, and concepts that check
if f(D) is available
```
template<class T, int I, int J> concept C = requires(T t) { f(t); I; };
// I makes atomic constrains different
// J makes concepts different (to avoid thoughts about re-instantiation)
struct D{} d;
///////////
// no f yet
assert(!C<D,1,1>); // obviously, no f to accept D
///////////////
// general case
void f(auto){}
assert(C<D,1,2>); // ERROR with detailed diagnostics:
// atomic constrain changed its value from false to true
assert(C<D,2,2>); // obviously, f(auto) accepts D
///////////////
// refined case
void f(D) = delete;
assert(!C<D,2,3>); // ERROR WITHOUT DIAGNOSTICS
// compiler silently assumed true from previous check.
assert(!C<D,3,3>); // obviously, f(D)=deleted
```
More wordy example is provided here: https://gcc.godbolt.org/z/vdxhTGEcc
In comparison with CLang, which works as predicted.
Note that static_asserts and bool constants work different.
Constants silently take some value.
I also reported this (and adjacent) issue here:
https://habr.com/ru/articles/857744/