-
Notifications
You must be signed in to change notification settings - Fork 15.3k
Closed
Labels
c++26clang:frontendLanguage frontend issues, e.g. anything involving "Sema"Language frontend issues, e.g. anything involving "Sema"confirmedVerified by a second partyVerified by a second partydiverges-from:gccDoes the clang frontend diverge from gcc on this issueDoes the clang frontend diverge from gcc on this issue
Description
MRE :
https://godbolt.org/z/Mjdnz8G31
#include <cassert>
template <class T>
struct A {
T _ = 5;
T _ = 4;
};
int main() {
A<int> a;
auto [x, y] = a;
assert( y == 4 );
}assert( y == 4 ) fails because Clang finds the in-class init pattern like this (in Sema::BuildCXXDefaultInitExpr) :
CXXRecordDecl *ClassPattern = ParentRD->getTemplateInstantiationPattern();
DeclContext::lookup_result Lookup = ClassPattern->lookup(Field->getDeclName());
FieldDecl *Pattern = nullptr;
for (auto *L : Lookup) {
if ((Pattern = dyn_cast<FieldDecl>(L)))
break;
}Obviously this cannot works with _. I think to remedy this imply keeping track of the pattern of an instantiated field with a placeholder name in some auxiliary structure? The entry would only need to be temporary until its consumed by Sema::BuildCXXDefaultInitExpr.
Also I think a warning should be emitted that we're using a C++26 feature before its time?
Metadata
Metadata
Assignees
Labels
c++26clang:frontendLanguage frontend issues, e.g. anything involving "Sema"Language frontend issues, e.g. anything involving "Sema"confirmedVerified by a second partyVerified by a second partydiverges-from:gccDoes the clang frontend diverge from gcc on this issueDoes the clang frontend diverge from gcc on this issue