From 27fce25cc07f7efe11db05eb2fe74a465c41475f Mon Sep 17 00:00:00 2001 From: Jonathan Wakely Date: Thu, 14 Sep 2023 09:18:34 +0100 Subject: [PATCH] libstdc++: Add workaround for std::make_integer_sequence bug [PR111357] The compiler bug has been fixed on trunk, but we need this workaround on the branches. libstdc++-v3/ChangeLog: PR c++/111357 * include/std/utility (make_integer_sequence): Add cast. * testsuite/20_util/integer_sequence/pr111357.cc: New test. (cherry picked from commit 7b0abd4a8ee9d2057febe443de67009dcdfe7574) --- libstdc++-v3/include/std/utility | 2 +- .../20_util/integer_sequence/pr111357.cc | 34 +++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 libstdc++-v3/testsuite/20_util/integer_sequence/pr111357.cc diff --git a/libstdc++-v3/include/std/utility b/libstdc++-v3/include/std/utility index f54f75b4d388..7ebb8a552c14 100644 --- a/libstdc++-v3/include/std/utility +++ b/libstdc++-v3/include/std/utility @@ -331,7 +331,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION #if __has_builtin(__make_integer_seq) = __make_integer_seq; #else - = integer_sequence<_Tp, __integer_pack(_Num)...>; + = integer_sequence<_Tp, __integer_pack(_Tp(_Num))...>; #endif /// Alias template index_sequence diff --git a/libstdc++-v3/testsuite/20_util/integer_sequence/pr111357.cc b/libstdc++-v3/testsuite/20_util/integer_sequence/pr111357.cc new file mode 100644 index 000000000000..1ad06b732afc --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/integer_sequence/pr111357.cc @@ -0,0 +1,34 @@ +// { dg-do compile { target c++14 } } + +// PR c++/111357 - __integer_pack fails to work with values of dependent type +// convertible to integers in noexcept context + +#include + +using std::integer_sequence; +using std::make_integer_sequence; + +template +void g(integer_sequence) +{} + +template +struct c1 +{ + static constexpr int value = 1; + constexpr operator int() { return value; } +}; + +template +struct R +{ + using S = make_integer_sequence{}>; + + R() noexcept(noexcept(g(S()))) // { dg-bogus "argument to .__integer_pack." } + {} +}; + +int main() +{ + R(); +} -- 2.47.2