diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 21b76292bca96..2362e479dfbbc 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -339,6 +339,9 @@ Bug Fixes in This Version (`#64462 `_) - Fixes a regression where the ``UserDefinedLiteral`` was not properly preserved while evaluating consteval functions. (`#63898 `_). +- Fix a crash when evaluating value-dependent structured binding + variables at compile time. + Fixes (`#67690 `_) Bug Fixes to Compiler Builtins ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp index a142ea7c47a47..d0e27de743604 100644 --- a/clang/lib/AST/ExprConstant.cpp +++ b/clang/lib/AST/ExprConstant.cpp @@ -3357,6 +3357,9 @@ static bool evaluateVarDeclInit(EvalInfo &Info, const Expr *E, return false; } + if (E->isValueDependent()) + return false; + // Dig out the initializer, and use the declaration which it's attached to. // FIXME: We should eventually check whether the variable has a reachable // initializing declaration. diff --git a/clang/test/SemaCXX/constant-expression-cxx1z.cpp b/clang/test/SemaCXX/constant-expression-cxx1z.cpp index 9335626a5c90a..c0766f70cf881 100644 --- a/clang/test/SemaCXX/constant-expression-cxx1z.cpp +++ b/clang/test/SemaCXX/constant-expression-cxx1z.cpp @@ -177,3 +177,16 @@ namespace LambdaCallOp { p(); } } + +// This used to crash due to an assertion failure, +// see gh#67690 +namespace { + struct C { + int x; + }; + + template void f() { + const auto &[c] = *p; + &c; // expected-warning {{expression result unused}} + } +}