[clang] [clang][bytecode] Use in Expr::tryEvaluateObjectSize() (PR #179197)

marius doerner via cfe-commits cfe-commits at lists.llvm.org
Mon Feb 2 03:19:43 PST 2026


mariusdr wrote:

I think my issue was that the pointer callback is never called when the expression evaluates to a function pointer
https://github.com/llvm/llvm-project/blob/aee5fa1f0c89ac68a2a2eeda7c5900d0a4508fd4/clang/lib/AST/ByteCode/EvalEmitter.cpp#L191-L204

This means that `tryEvaluateObjectSize` returns without actually setting an object size in `Result` leaving the variable basically unitialised here

https://github.com/llvm/llvm-project/blob/aee5fa1f0c89ac68a2a2eeda7c5900d0a4508fd4/clang/lib/Sema/SemaChecking.cpp#L1219-L1223

hitting UB. While the AST interpreter recognizes this case by inspecting the type for `isFunctionType` and returns false.

  auto CheckedHandleSizeof = [&](QualType Ty, CharUnits &Result) {
    if (Ty.isNull())
      return false;


    Ty = Ty.getNonReferenceType();


    if (Ty->isIncompleteType() || Ty->isFunctionType())
      return false;



https://github.com/llvm/llvm-project/pull/179197


More information about the cfe-commits mailing list