https://gcc.gnu.org/g:91567f852bf94671d0e30e867ae9e4ba87ccb86b
commit 91567f852bf94671d0e30e867ae9e4ba87ccb86b Author: Alexandre Oliva <ol...@adacore.com> Date: Thu May 15 05:11:23 2025 -0300 [testsuite] tolerate missing std::stold basic_string.h doesn't define the non-w string version of std::stold when certain conditions aren't met, and then a couple of tests fail to compile. Guard the portions of the tests that depend on std::stold with the conditions for it to be defined. for libstdc++-v3/ChangeLog * testsuite/21_strings/basic_string/numeric_conversions/char/stold.cc: Guard non-wide stold calls with conditions for it to be defined. * testsuite/27_io/basic_ostream/inserters_arthmetic/char/hexfloat.cc: Likewise. Diff: --- .../21_strings/basic_string/numeric_conversions/char/stold.cc | 6 ++++++ .../27_io/basic_ostream/inserters_arithmetic/char/hexfloat.cc | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stold.cc b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stold.cc index b64ad0c86834..dd777c4529a0 100644 --- a/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stold.cc +++ b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stold.cc @@ -31,6 +31,11 @@ void test01() { + /* If these conditions are not met, basic_string.h doesn't define + std::stold(const string&, size_t* = 0), and then the test would + fail to compile. */ +#if (_GLIBCXX_HAVE_STRTOLD && ! _GLIBCXX_HAVE_BROKEN_STRTOLD) \ + || __DBL_MANT_DIG__ == __LDBL_MANT_DIG__ bool test = false; using namespace std; @@ -106,6 +111,7 @@ test01() test = false; } VERIFY( test ); +#endif } int main() diff --git a/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_arithmetic/char/hexfloat.cc b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_arithmetic/char/hexfloat.cc index b1bc7fbb9d4e..f694730901ed 100644 --- a/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_arithmetic/char/hexfloat.cc +++ b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_arithmetic/char/hexfloat.cc @@ -95,6 +95,11 @@ test01() void test02() { + /* If these conditions are not met, basic_string.h doesn't define + std::stold(const string&, size_t* = 0), and then the test would + fail to compile. */ +#if (_GLIBCXX_HAVE_STRTOLD && ! _GLIBCXX_HAVE_BROKEN_STRTOLD) \ + || __DBL_MANT_DIG__ == __LDBL_MANT_DIG__ ostringstream os; long double d = 272.L; // 0x1.1p+8L; os << hexfloat << setprecision(1); @@ -140,6 +145,7 @@ test02() cout << "got: " << os.str() << endl; #endif VERIFY( os && os.str() == "15" ); +#endif } int