[libc-commits] [libc] [libc][NFC] Fix GCC volatile warning (PR #78509)
via libc-commits
libc-commits at lists.llvm.org
Wed Jan 17 14:46:54 PST 2024
lntue wrote:
The intention of `volatile` was to force the conversion to double for each rounding mode inside the macro `EXPECT_FP_EQ_ALL_ROUNDING`: https://github.com/llvm/llvm-project/blob/main/libc/test/UnitTest/FPMatcher.h#L190
Without forcing re-evaluation, the compiler will optimize and only use the default rounding mode output of the conversion for all the rounding modes.
It seems to work properly on clang, and probably because gcc ignores the attribute, this test failed on gcc?
A proper fix is probably updating the `EXPECT_FP_EQ_ALL_ROUNDING` in every rounding mode check as:
```
if (__r.success) {
volatile auto e = (expected);
volatile auto a = (actual);
EXPECT_FP_EQ(e, a);
}
```
https://github.com/llvm/llvm-project/pull/78509
More information about the libc-commits
mailing list