-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Non-bool, non-constant expressions in requires clauses: SFINAE or hard error?
#45
Comments
|
Actually, what is happening here is related to a deeper problem - the trailing requires clause of the first f is instantiated as part of the template instantiation, which causes a SFINAE error, which is why that f is not participating. http://eel.is/c++draft/temp.constr.constr#temp.constr.atomic-3 leads me to think GCC's right here. |
|
Oh, gross. http://eel.is/c++draft/temp.constr.constr#temp.constr.atomic-3 currently says:
So:
This makes @saarraz, I strongly believe that Clang should implementation-define the undefined behavior here. In the cases where the paper standard leaves the language's behavior undefined, Clang should act as if the constraint was unsatisfied (and thus the overload in question should SFINAE away). |
|
Isn't this behavior a bit confusing to people who don't know the rules? Someone can use an int as a condition and expect it to act like it would in an |
|
"shall" is a diagnosable constraint in Core wording: non-constant expressions and expressions of non- I agree that it's insane that these corner cases produce an ill-formed program rather than resulting in the dissatisfaction of the concept, but Core is more concerned about the potential for writing buggy concepts that are never satisfied than the fact that these rules are extremely novice-hostile. (See http://lists.isocpp.org/ext/2018/08/5383.php which requires reflector access.) |
|
@CaseyCarter, your message in http://lists.isocpp.org/ext/2018/08/5383.php sounds accurate to me. It is crazy that the overload set https://godbolt.org/z/Snbyrm should give hard errors on types like |
|
Fixed in 05d5da4 |
https://concepts.godbolt.org/z/MTt3Hc
Clang claims
f<int>()is unambiguous (the constrainedfdoesn't participate in overload resolution becauseint(x)is not boolish).Clang claims
f<bool&>()is a hard error (the constrainedfproduces a hard error because(bool&)(x)is not a constant-expression).FWIW, here's GCC's behavior:
GCC claims
f<int>()is a hard error (the constrainedfproduces a hard error becauseint(x)is not boolish).GCC claims
f<bool&>()is a hard error (the constrainedfproduces a hard error because(bool&)(x)is not a constant-expression).I suspect that the correct behavior would be to treat both
f<int>()andf<bool&>()as unambiguous.The text was updated successfully, but these errors were encountered: