From 207534061fb026585d65af3cf863dc434ec36d7c Mon Sep 17 00:00:00 2001 From: Alexandre Oliva Date: Wed, 21 May 2025 06:20:11 -0300 Subject: [PATCH] [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_arithmetic/char/hexfloat.cc: Likewise. --- .../basic_string/numeric_conversions/char/stold.cc | 6 ++++++ .../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 -- 2.47.2