[clang] [Clang] Fix offsetof sign-extending unsigned array indices >= 128 (PR #204139)
Marlus Cadanus da Costa via cfe-commits
cfe-commits at lists.llvm.org
Tue Jun 23 07:02:22 PDT 2026
================
@@ -3799,10 +3799,29 @@ bool Compiler<Emitter>::VisitOffsetOfExpr(const OffsetOfExpr *E) {
continue;
}
+ if (IndexT == PT_IntAP || IndexT == PT_IntAPS) {
+ // AP types (e.g. __uint128_t, __int128) cannot be safely cast to
+ // Sint64. Evaluate the constant and push it directly as Sint64.
+ Expr::EvalResult EvalResult;
+ if (!ArrayIndexExpr->EvaluateAsInt(EvalResult, Ctx.getASTContext()))
----------------
marlus wrote:
Fixed. Removed EvaluateAsInt from the compiler entirely. As suggested by @efriedma-quic, implemented a CastNoOverflow bytecode opcode instead.
https://github.com/llvm/llvm-project/pull/204139
More information about the cfe-commits
mailing list