Consider the following example:
void f() requires true { }
int main() { f(); }
Clang(1) (DEMO) accepts this program, whereas GCC(1) (DEMO) rejects it with the following error:
error: constraints on a non-templated function
Note that the constraint expression can actually be used in Clang's case, as the following program is rejected by Clang:
void f() requires false { }
int main() { f(); } // // error: no matching function for call to 'f'
with Clang noting that that the declared f is not a candidate as the constraints were not satisfied (for it to be a candidate for the f() call; DEMO).
- Which compiler is correct here, and what is(/are) the relevant standard rule(/s) that govern this?
(1) GCC HEAD 11.0.0 20210124 and Clang HEAD 12.0.0 (20210124), -std=c++20.