-
Notifications
You must be signed in to change notification settings - Fork 13.5k
c11: _Atomic not removed from rvalue in controlling expression of _Generic. #39595
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
Comments
The cited sections of the standard are relevant but don't actually point out where we've gone wrong (we properly implement those paragraphs as far as I can see). The issue is that we don't implement all of the changes in WG14 DR 423; critically we seem to miss the changes to 6.7.6.3p4, which cause the declaration of the function to drop the qualifiers. You can see this in an AST dump:
yields:
The signature for those functions should not have the qualifiers in C (but should retain them in C++). Once we resolve that issue, this code should begin to work properly. |
I made https://reviews.llvm.org/D125919 to address this. |
@llvm/issue-subscribers-clang-frontend |
Doing that you have unexpectedly compromised source code fidelity of the AST as the presence of qualifiers in return type is lost also in TypeSourceInfo. |
Hmm, yes, I think that is worth a new issue. Good catch, @Abramo-Bagnara! |
Thanks @AaronBallman. I've just filed issue #55778. |
Reopening this issue due to reverting the changes in c745f2c |
This is a duplicate of #39494 because it relates to not implementing DR423. |
Extended Description
Test case (prog.c):
_Atomic int f();
int main()
{
_Generic(f(), int: 0);
}
Compilation command line:
clang prog.c -Wall -Wextra -std=c11 -pedantic-errors
Observed behaviour:
The following error message was outputed:
Expected behaviour:
No error message.
The program is well-formed.
See 6.5.1.1/2:
"The type of the controlling expression is the type of the expression as if it
had undergone an lvalue conversion, array to pointer conversion, or function
to pointer conversion"
and 6.3.2/2:
"If the lvalue has qualified type, the value has the unqualified version
of the type of the lvalue; additionally, if the lvalue has atomic type, the
value has the non-atomic version of the type of the lvalue; otherwise, the
value has the type of the lvalue."
Note:
GCC accepts the program without outputing any error message.
The text was updated successfully, but these errors were encountered: