libstdc++: Fix constexpr memory algo tests for COW std::string

The old COW std::string is not usable in constant expressions, so these
new tests fail with -D_GLIBCXX_USE_CXX11_ABI=0.

The parts of the tests using std::string can be conditionally skipped.

libstdc++-v3/ChangeLog:

	* testsuite/20_util/specialized_algorithms/uninitialized_copy/constexpr.cc:
	Do not test COW std::string in constexpr contexts.
	* testsuite/20_util/specialized_algorithms/uninitialized_default_construct/constexpr.cc:
	Likewise.
	* testsuite/20_util/specialized_algorithms/uninitialized_fill/constexpr.cc:
	Likewise.
	* testsuite/20_util/specialized_algorithms/uninitialized_move/constexpr.cc:
	Likewise.
	* testsuite/20_util/specialized_algorithms/uninitialized_value_construct/constexpr.cc:
	Likewise.

Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
This commit is contained in:
Jonathan Wakely 2025-03-06 11:24:03 +00:00 committed by Jonathan Wakely
parent d6d7da92fb
commit 6eede5ad12
No known key found for this signature in database
5 changed files with 10 additions and 0 deletions

View file

@ -51,7 +51,9 @@ test01()
test01_impl<char>({'a', 'b', 'c'}) &&
test01_impl<int>({1, 2, 3, 4}) &&
test01_impl<double>({1.0, 2.0, 3.0, 4.0}) &&
#if _GLIBCXX_USE_CXX11_ABI
test01_impl<std::string>({"a", "b", "cc", "dddd", "eeeeeeeeeeeeeeee"}) &&
#endif
test01_impl<std::vector<int>>({ {0}, {0, 1}, {0, 1, 2}});
}

View file

@ -59,7 +59,9 @@ test01()
test01_impl<char>() &&
test01_impl<int>() &&
test01_impl<double>() &&
#if _GLIBCXX_USE_CXX11_ABI
test01_impl<std::string>() &&
#endif
test01_impl<std::vector<int>>() &&
test01_impl<std::unique_ptr<int>>();
}

View file

@ -58,8 +58,10 @@ test01()
test01_impl<int>(0) &&
test01_impl<int>(42) &&
test01_impl<double>(3.14) &&
#if _GLIBCXX_USE_CXX11_ABI
test01_impl<std::string>() &&
test01_impl<std::string>(std::string("test")) &&
#endif
test01_impl<std::vector<int>>() &&
test01_impl<std::vector<int>>({1, 2, 3, 4}) &&
test01_impl<std::unique_ptr<int>>(nullptr);

View file

@ -43,7 +43,9 @@ test01()
test01_impl<char>({'a', 'b', 'c'}) &&
test01_impl<int>({1, 2, 3, 4}) &&
test01_impl<double>({1.0, 2.0, 3.0, 4.0}) &&
#if _GLIBCXX_USE_CXX11_ABI
test01_impl<std::string>({"a", "b", "cc", "dddd", "eeeeeeeeeeeeeeee"}) &&
#endif
test01_impl<std::vector<int>>({ {0}, {0, 1}, {0, 1, 2}}) &&
test01_impl<std::unique_ptr<int>>(std::vector<std::unique_ptr<int>>(10));
}

View file

@ -56,7 +56,9 @@ test01()
test01_impl<char>() &&
test01_impl<int>() &&
test01_impl<double>() &&
#if _GLIBCXX_USE_CXX11_ABI
test01_impl<std::string>() &&
#endif
test01_impl<std::vector<int>>() &&
test01_impl<std::unique_ptr<int>>();
}