[libc][C++23] f16 floating-point literals are used when building LLVM with -std=c++17
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
### Environment
- LLVM: main (please replace with the commit hash if possible)
- Compiler: GCC
- CMake:
- Build configuration:
- CMAKE_CXX_STANDARD=17
### Description
While building LLVM with `CMAKE_CXX_STANDARD=17`, GCC emits `-Wpedantic`
warnings because `libc/src/__support/math/erfcf16.h` and
[libc/src/__support/math/erff16.h](https://github.com/llvm/llvm-project/blob/main/libc/src/__support/math/erfcf16.h#L95) use the `f16` floating-point literal
suffix, which is a C++23 language feature.
For example:
```cpp
if (LIBC_UNLIKELY(x_abs == 0))
return 1.0f16;
```
***Warning***
```python
/root/llvm/llvm-project/llvm/../libc/src/__support/math/erfcf16.h:96:5: warning: ‘f16’ or ‘F16’ suffix on floating constant only available with ‘-std=c++2b’ or ‘-std=gnu++2b’ [-Wpedantic]
/root/llvm/llvm-project/llvm/../libc/src/__support/math/erfcf16.h:112:5: warning: ‘f16’ or ‘F16’ suffix on floating constant only available with ‘-std=c++2b’ or ‘-std=gnu++2b’ [-Wpedantic]
/root/llvm/llvm-project/llvm/../libc/src/__support/math/erff16.h:137:7: warning: ‘f16’ or ‘F16’ suffix on floating constant only available with ‘-std=c++2b’ or ‘-std=gnu++2b’ [-Wpedantic]
/root/llvm/llvm-project/llvm/../libc/src/__support/math/erff16.h:137:7: warning: ‘f16’ or ‘F16’ suffix on floating constant only available with ‘-std=c++2b’ or ‘-std=gnu++2b’ [-Wpedantic]
/root/llvm/llvm-project/llvm/../libc/src/__support/math/erff16.h:147:3: warning: ‘f16’ or ‘F16’ suffix on floating constant only available with ‘-std=c++2b’ or ‘-std=gnu++2b’ [-Wpedantic]
```
**Question**
```bash
`LLVM` is configured to build with `CMAKE_CXX_STANDARD=17`, but these headers use the `C++23` f16 floating-point literal suffix.
Should these headers avoid `C++23` only language features and use a `C++17` compatible alternative instead?
```
Contributor guide
Assessment
This issue has not been assessed yet.