Skip to content
Snippets Groups Projects
Commit 6261d105 authored by Jonathan Wakely's avatar Jonathan Wakely
Browse files

libstdc++: Make std::numeric_limits<__float128> more portable [PR104772]


This redefines std::numeric_limits<__float128> so that it works with
non-GCC compilers. The previous definition didn't work with Clang, due
to it not supporting __builtin_high_valq, __builtin_nanq, and
__builtin_nansq. It also didn't work in strict modes, due to using Q
literal suffixes.

The new definition uses the Q suffixes when supported, or calculates the
correct values using __float128 arithmetic from double values. Ideally
the values would be defined as hexadecimal-floating-point-literals, but
that won't work for C++14 and older.

The only member that can't be defined this way is signaling_NaN() which
still requires a built-in. If __builtin_nansq is not supported, try to
use __builtin_nansf128 (with a possibly-redundant bit_cast) and if that
isn't supported, return a quiet NaN and define has_signaling_NaN and
is_iec754 to be false.

libstdc++-v3/ChangeLog:

	PR libstdc++/104772
	* include/std/limits: (numeric_limits<__float128>): Define
	for __STRICT_ANSI__ as well.
	* testsuite/18_support/numeric_limits/128bit.cc: Remove
	check for __STRICT_ANSI__.

Co-authored-by: default avatarJakub Jelinek <jakub@redhat.com>
parent 97a5e8a2
No related branches found
No related tags found
No related merge requests found
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment