================
@@ -18606,12 +18606,15 @@ bool IntExprEvaluator::VisitCastExpr(const CastExpr
*E) {
if (!Result.isInt()) {
// Allow casts of address-of-label differences if they are no-ops
- // or narrowing. (The narrowing case isn't actually guaranteed to
+ // or narrowing, if the result is at least 32 bits wide.
+ // (The narrowing case isn't actually guaranteed to
// be constant-evaluatable except in some narrow cases which are hard
// to detect here. We let it through on the assumption the user knows
// what they are doing.)
- if (Result.isAddrLabelDiff())
- return Info.Ctx.getTypeSize(DestType) <= Info.Ctx.getTypeSize(SrcType);
+ if (Result.isAddrLabelDiff()) {
+ unsigned DestBits = Info.Ctx.getTypeSize(DestType);
+ return DestBits >= 32 && DestBits <= Info.Ctx.getTypeSize(SrcType);
+ }
----------------
zygoloid wrote:
> The bug report says "The following testcase distilled from glibc's vfprintf
> [...]".
Ah, the macro obscured this enough that my regex didn't find this one. That's
still there, and has a comment saying they're intentionally using `int` even on
64-bit systems to save space.
https://github.com/llvm/llvm-project/pull/171437
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits