[libc-commits] [libc] [libc] Workaround for gcc complaining about implicit conversions with the ternary ?: operator. (PR #124820)

via libc-commits libc-commits at lists.llvm.org
Tue Jan 28 12:28:01 PST 2025


lntue wrote:

> Can you walk me through here (or in the PR/commit description) what's going on here? Where were the implicit conversions; how does this patch fix them?

For some reason, gcc promotes the ternary
```
sign ? values[i].rnd_downward_offset : values[i].rnd_upward_offset
```
to `int` when adding to `out_bits +=`, even though all of them are of `StorageType`, aka `uint16_t`, here.

And they stop the integer promotion when splitting the ternary operations to conditionals.

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


More information about the libc-commits mailing list