llvm / llvm/llvm-project

[libc][C++23] f16 floating-point literals are used when building LLVM with -std=c++17

Open
#207,380 2 comments 0 reactions 2 assignees Claimed by @GANESH330024 View on GitHub
c++23 libc
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.