Skip to content

Add support for C23 interchange float types (_Float32, _Float64, _Float128, ...) #97335

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
tgross35 opened this issue Jul 1, 2024 · 4 comments
Labels
c23 clang:frontend Language frontend issues, e.g. anything involving "Sema"

Comments

@tgross35
Copy link
Contributor

tgross35 commented Jul 1, 2024

Newer versions of C allow the following relevant interchange types:

  • _Float16: 16-bit IEEE floating point numbers
  • _Float32: 32-bit IEEE floating point numbers
  • _Float64: 64-bit IEEE floating point numbers
  • _Float64x: Extended 64-bit IEEE floating point numbers (e.g. x86 f80 long double)
  • _Float128: 128-bit IEEE floating point numbers
  • _FloatN _Complex
  • Suffix F16/f16
  • Suffix F32/f32
  • Suffix F64/f64
  • Suffix F64x/f64x
  • Suffix F128/f128

GCC currently supports all of these. Clang currently supports only _Float16, but should add the rest.

Link to the draft: https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2601.pdf
Link to demo: https://clang.godbolt.org/z/5xbq9919z

C++ also supports the same suffixes for the std types, https://en.cppreference.com/w/cpp/types/floating-point

It sounds like these can't simply be redefines of float and double, see #50110 (cc @AaronBallman)

@tgross35 tgross35 changed the title Add support for _Float32 and _Float64 in C Add support for _Float32, _Float64, and _Float128 in C Jul 1, 2024
@EugeneZelenko EugeneZelenko added clang:frontend Language frontend issues, e.g. anything involving "Sema" extension:gnu and removed new issue labels Jul 1, 2024
@llvmbot
Copy link
Member

llvmbot commented Jul 1, 2024

@llvm/issue-subscribers-clang-frontend

Author: Trevor Gross (tgross35)

GCC supports `_Float32` and `_Float64` in both C and C++, with the associated `F32`, `F64`, and `F128` literal suffixes. Clang should add support for these to be compatible.

It sounds like these can't simply be redefines of float and double, see #50110 (cc @AaronBallman)

@pinskia
Copy link

pinskia commented Jul 1, 2024

Note this is not exactly a GNU extension but for compatibility with GCC (via C23 defined extended floating point types).

@tgross35
Copy link
Contributor Author

tgross35 commented Jul 1, 2024

Yes thanks, I updated the top post to give more context. It seems like GCC does not restrict these types to only --std=c23.

@tgross35 tgross35 changed the title Add support for _Float32, _Float64, and _Float128 in C Add support for C23 float types (_Float32, _Float64, and _Float128) Jul 1, 2024
@tgross35 tgross35 changed the title Add support for C23 float types (_Float32, _Float64, and _Float128) Add support for C23 float types (_Float32, _Float64, _Float128, ...) Jul 1, 2024
@tgross35 tgross35 changed the title Add support for C23 float types (_Float32, _Float64, _Float128, ...) Add support for C23 interchange float types (_Float32, _Float64, _Float128, ...) Jul 1, 2024
saagarjha pushed a commit to ahjragaas/glibc that referenced this issue Dec 21, 2024
tgmath3-macro-tests won't compile with <float.h> and <tgmath.h> from
Clang due to missing C23 support:

llvm/llvm-project#97335

Disable them for now when Clang is used for testing so that "make check"
can finish.

Signed-off-by: H.J. Lu <[email protected]>
@EugeneZelenko EugeneZelenko marked this as a duplicate of #63642 Dec 25, 2024
@fweimer-rh
Copy link
Contributor

Please note that glibc headers define _Float64 et al. by default and have a built-in list of compiler versions which provide their own definitions of these types. We can certainly backport the required header changes to make this conditional on Clang version, but it might be more developer-friendly to accept compatible redefinitions of _Float64 et al.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c23 clang:frontend Language frontend issues, e.g. anything involving "Sema"
Projects
None yet
Development

No branches or pull requests

5 participants