[clang] [Clang] Diagnose invalid object size kinds during constant evaluation (PR #230979)
Timm Baeder via cfe-commits
cfe-commits at lists.llvm.org
Sun Oct 11 09:05:09 PDT 2026
================
@@ -17176,10 +17176,13 @@ bool IntExprEvaluator::VisitBuiltinCallExpr(const CallExpr *E,
case Builtin::BI__builtin_dynamic_object_size:
case Builtin::BI__builtin_object_size: {
- // The type was checked when we built the expression.
- unsigned Type =
- E->getArg(1)->EvaluateKnownConstInt(Info.Ctx).getZExtValue();
- assert(Type <= 3 && "unexpected type");
+ APSInt TypeValue = E->getArg(1)->EvaluateKnownConstInt(Info.Ctx);
----------------
tbaederr wrote:
Since we completely disable range checks in `BuiltinConstantArgRange` in a constant context, this is also not a "known" const int:
```
_Static_assert(__builtin_object_size((void*)0, 1/0), "");
```
https://github.com/llvm/llvm-project/pull/230979
More information about the cfe-commits
mailing list