Description
The following code demonstrates the issue:
struct{
const int c;
}foo();
puts(_Generic(foo().c,int:"A",const int:"B"));
foo
returns a structure that contains a qualified member named c
of type const int
. Calling foo
results in an rvalue structure, which when accessing one of the members via .
results in an rvalue. Clang does not remove qualifiers or _Atomic (C23 removes _Atomic from rvalues as well, and GCC does this in earlier versions as well) here while GCC does and the result of DR 423 seems intended to remove cases of qualified rvalues. Additionally, Clang actually generates a warning here with the default warnings stating that the const int
branch will never be taken (and then it takes it anyway). The wording doesn't state that the result is the non-atomic (C23) and unqualified member when getting the member though I assume that is a defect.