[libc-commits] [libc] [libc] Workaround for gcc complaining about implicit conversions with the ternary ?: operator. (PR #124820)
Nick Desaulniers via libc-commits
libc-commits at lists.llvm.org
Tue Jan 28 12:58:26 PST 2025
================
@@ -81,12 +81,16 @@ template <typename T, size_t N> struct ExceptValues {
StorageType out_bits = values[i].rnd_towardzero_result;
switch (fputil::quick_get_round()) {
case FE_UPWARD:
- out_bits += sign ? values[i].rnd_downward_offset
- : values[i].rnd_upward_offset;
+ if (sign)
+ out_bits += values[i].rnd_downward_offset;
+ else
+ out_bits += values[i].rnd_upward_offset;
----------------
nickdesaulniers wrote:
Looking at https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101537, I think you can keep the ternary, and instead work around this as such:
```suggestion
// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101537
out_bits = out_bits + (sign ? values[i].rnd_downward_offset : values[i].rnd_upward_offset);
```
ah, but that's not much more readable. Please cite https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101537 in either a comment in the sources and/or the PR description.
https://github.com/llvm/llvm-project/pull/124820
More information about the libc-commits
mailing list