[pushed] c++: extend Wdangling-reference17.C [PR109642]
Checks
Commit Message
Tested x86_64-pc-linux-gnu, applying to trunk.
-- >8 --
This patch extends g++.dg/warn/Wdangling-reference17.C with code
from PR109642. I'm not creating a new test because this one
already #includes the required headers.
PR c++/109642
gcc/testsuite/ChangeLog:
* g++.dg/warn/Wdangling-reference17.C: Additional testing.
---
gcc/testsuite/g++.dg/warn/Wdangling-reference17.C | 12 ++++++++++++
1 file changed, 12 insertions(+)
base-commit: bc77c035c45bb224790b1c03d06a64c8a1cc51c5
@@ -4,6 +4,7 @@
#include <vector>
#include <ranges>
+#include <span>
int main()
{
@@ -12,4 +13,15 @@ int main()
{
(void) i;
}
+
+ // From c++/109642.
+ const auto vec = std::vector{ 1, 2, 3 };
+ const auto s = std::span<decltype(vec)::value_type const>{vec};
+
+ for ([[maybe_unused]] auto _ : s | std::views::take(2)) { }
+
+ for ([[maybe_unused]] auto _ : vec | std::views::take(2)) { }
+
+ const auto s_view = s | std::views::take(2);
+ for ([[maybe_unused]] auto _ : s_view) { }
}