[libc-commits] [libc] [libc] Fix warnings emitted by GCC (PR #98751)

via libc-commits libc-commits at lists.llvm.org
Sat Jul 13 09:15:41 PDT 2024


================
@@ -264,7 +265,11 @@ TEST(LlvmLibcUIntClassTest, BitCastToFromNativeFloat128) {
 TEST(LlvmLibcUIntClassTest, BitCastToFromNativeFloat16) {
   static_assert(cpp::is_trivially_copyable<LL_UInt16>::value);
   static_assert(sizeof(LL_UInt16) == sizeof(float16));
-  const float16 array[] = {0, 0.1, 1};
+  const float16 array[] = {
+      static_cast<float16>(0.0),
+      static_cast<float16>(0.1),
+      static_cast<float16>(1.0),
+  };
----------------
overmighty wrote:

Using `static_cast<float16>` because using the `f16` suffix on the literals would cause this warning instead:

```
warning: ‘f16’ or ‘F16’ suffix on floating constant only available with ‘-std=c++2b’ or ‘-std=gnu++2b’ [-Wpedantic]
```

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


More information about the libc-commits mailing list