[clang] [clang][ExprConst] Fix crash on uninitialized array subobject (PR #67817)
Aaron Ballman via cfe-commits
cfe-commits at lists.llvm.org
Fri Oct 13 09:55:37 PDT 2023
================
@@ -2411,10 +2411,15 @@ static bool CheckEvaluationResult(CheckEvaluationResultKind CERK,
const FieldDecl *SubobjectDecl,
CheckedTemporaries &CheckedTemps) {
if (!Value.hasValue()) {
- assert(SubobjectDecl && "SubobjectDecl shall be non-null");
- Info.FFDiag(DiagLoc, diag::note_constexpr_uninitialized) << SubobjectDecl;
- Info.Note(SubobjectDecl->getLocation(),
- diag::note_constexpr_subobject_declared_here);
+ if (SubobjectDecl) {
+ Info.FFDiag(DiagLoc, diag::note_constexpr_uninitialized)
+ << true << SubobjectDecl;
+ Info.Note(SubobjectDecl->getLocation(),
+ diag::note_constexpr_subobject_declared_here);
+ } else {
+ // FIXME: We should add a test to check the output of this case.
+ Info.FFDiag(DiagLoc, diag::note_constexpr_uninitialized) << false << Type;
----------------
AaronBallman wrote:
I think we should add that test case now as this is a new code path we previously didn't have.
https://github.com/llvm/llvm-project/pull/67817
More information about the cfe-commits
mailing list