[Mlir-commits] [mlir] [mlir] Fix UBSan signed overflow when printing/parsing affine INT64_MIN constants (PR #186155)

Javier Setoain llvmlistbot at llvm.org
Thu Mar 12 10:08:13 PDT 2026


================

----------------
jsetoain wrote:

A couple of issues here. If that `getValue()` call is returning `9223372036854775808LU` as an `int64_t` type, negated is the exact same value (`0x8000000000000000`), so I struggle to understand how that bit of code is different from:
```c++
return lhs + build.getAffineConstantExpr(-constRhs.getValue());
```

Other than that, if this is an issue, why not fix it at the source, in `AffineExpr::operator-(AffineExpr other)`? I reckon that might fix bugs, known or unknown, in other places. Or is this a very specific parser issue, and the other behavior is correct everywhere else?

As a nitpick, the mix of C++ and C style castings is a bit awkward.

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


More information about the Mlir-commits mailing list