[PATCH] D132918: [clang] Fix a crash in constant evaluation
Ilya Biryukov via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Sep 2 07:16:30 PDT 2022
ilya-biryukov added a comment.
I was just passing by, but wanted to add more context from our investigation with @kadircet.
If variables with incomplete types appear inside non-template `constexpr` function this gets detected by a call to `CheckConstexprFunctionDefinition` inside `ActOnFinishFunctionBody`:
if (!IsInstantiation && FD && FD->isConstexpr() && !FD->isInvalidDecl() &&
!CheckConstexprFunctionDefinition(FD, CheckConstexprKind::Diagnose))
FD->setInvalidDecl();
So the resulting `constexpr` function is marked as invalid and Clang does not attempt to evaluate its body.
However, `CheckConstexprFunctionDefinition` does not run for template function instantiation, so the `VarDecl` marked invalid ends up inside a valid `constexpr` function and Clang does run the evaluation.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D132918/new/
https://reviews.llvm.org/D132918
More information about the cfe-commits
mailing list