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.

Regstrapped on x86_64-linux-gnu.  Also tested with gcc-14 on aarch64-,
arm-, x86-, and x86_64-vxworks7r2.  Ok to install?


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.
---
 .../basic_string/numeric_conversions/char/stold.cc |    6 ++++++
 .../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 b64ad0c868345..dd777c4529a08 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 b1bc7fbb9d4e1..f694730901edb 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

-- 
Alexandre Oliva, happy hacker            https://blog.lx.oliva.nom.br/
Free Software Activist     FSFLA co-founder     GNU Toolchain Engineer
More tolerance and less prejudice are key for inclusion and diversity.
Excluding neuro-others for not behaving ""normal"" is *not* inclusive!

Reply via email to