-
Notifications
You must be signed in to change notification settings - Fork 15.3k
Closed
Labels
clang:frontendLanguage frontend issues, e.g. anything involving "Sema"Language frontend issues, e.g. anything involving "Sema"constevalC++20 constevalC++20 constevaldiverges-from:gccDoes the clang frontend diverge from gcc on this issueDoes the clang frontend diverge from gcc on this issuediverges-from:msvcDoes the clang frontend diverge from msvc on this issueDoes the clang frontend diverge from msvc on this issue
Description
As far as I can tell, the following should be well-formed:
consteval auto f() -> int {
struct Pair { int first; int second; };
Pair arr[] = {{1, 1}};
for (auto const& [key, value] : arr) {
[=] { [[maybe_unused]] int s = key; }();
}
return 0;
}
int p = f();https://compiler-explorer.com/z/5cGfrMTd7
GCC and MSVC accept; Clang and EDG reject, but EDG has acknowledged their behavior as a bug.
I did some preliminary digging, and the issue looks to occur while computing the lvalue-to-rvalue conversion of the DeclRefExpr that names key in the initializer of s; the findCompleteObject routine seems to be tripping over the structured binding and returns an empty CompleteObject here.
Metadata
Metadata
Assignees
Labels
clang:frontendLanguage frontend issues, e.g. anything involving "Sema"Language frontend issues, e.g. anything involving "Sema"constevalC++20 constevalC++20 constevaldiverges-from:gccDoes the clang frontend diverge from gcc on this issueDoes the clang frontend diverge from gcc on this issuediverges-from:msvcDoes the clang frontend diverge from msvc on this issueDoes the clang frontend diverge from msvc on this issue