diff options
author | Simon Tatham <simon.tatham@arm.com> | 2025-03-14 11:57:25 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-03-14 11:57:25 +0000 |
commit | 80079c9c2f55ddfc5b1d5235d5ed6a2981fa6a97 (patch) | |
tree | 492058f390611ccceacc0790a12c0b37fd7a5a47 /llvm/lib/CodeGen/CodeGen.cpp | |
parent | e45090e5f0bf7743fe0b00d510a903a659354ce1 (diff) | |
download | llvm-80079c9c2f55ddfc5b1d5235d5ed6a2981fa6a97.zip llvm-80079c9c2f55ddfc5b1d5235d5ed6a2981fa6a97.tar.gz llvm-80079c9c2f55ddfc5b1d5235d5ed6a2981fa6a97.tar.bz2 |
[libc] Fix new warning in DyadicFloat::as_mantissa_type_rounded (#131148)
The affected line of code converts a float's exponent from `int` to
`size_t`, negating it in the process. Following clang commit
773e88f9d61399c, this provokes a warning, presumably because the
conversion goes wrong if `size_t` is wider than `int` and the input
value is `INT_MIN`: negating it within the `int` type is undefined
behavior, with the likely (though not guaranteed) effect of leaving it
still at `INT_MIN` and then sign-extending that on promotion to
`size_t`.
This fix adds a cast so that the promotion to `size_t` happens _before_
the negation, so that the negative input value will _always_ be
sign-extended, and then the negation will make it positive again.
(I don't believe this case will actually come up. `DyadicFloat` is a
helper system used in processing ordinary float formats, so nothing is
expected to generate an exponent with even a 16-bit absolute value, let
alone 31. But it's as easy to fix it to be robust as it is to just
suppress the warning!)
Diffstat (limited to 'llvm/lib/CodeGen/CodeGen.cpp')
0 files changed, 0 insertions, 0 deletions