https://github.com/tbaederr updated https://github.com/llvm/llvm-project/pull/67778
>From 04abbd57c0325ea0c1d5d5af6fafa18c0c0410ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= <tbae...@redhat.com> Date: Fri, 29 Sep 2023 11:23:55 +0200 Subject: [PATCH] [clang][ExprConst] Don't try to evaluate value-dependent DeclRefExprs The Expression here migth be value dependent, which makes us run into an assertion later on. Just bail out early. Fixes #67690 --- clang/lib/AST/ExprConstant.cpp | 3 +++ clang/test/SemaCXX/constant-expression-cxx1z.cpp | 13 +++++++++++++ 2 files changed, 16 insertions(+) diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp index fea06b97259fe31..8372d81234669fd 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 9335626a5c90a4f..45f87f0cfcf808b 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 <const C *p> void f() { + const auto &[c] = *p; + &c; // expected-warning {{expression result unused}} + } +} _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits