Fix '23_containers/span/at.cc' for '-fno-exceptions' configurations (was: [committed] libstdc++: Add std::span::at for C++26 (P2821R5))
Checks
Commit Message
Hi!
On 2023-11-21T16:10:17+0000, Jonathan Wakely <jwakely@redhat.com> wrote:
> Tested x86_64-linux. Pushed to trunk.
> --- /dev/null
> +++ b/libstdc++-v3/testsuite/23_containers/span/at.cc
Pushed to master branch commit 762b428815d4e762abdff5c1ffc1e9aa60da7870
"Fix '23_containers/span/at.cc' for '-fno-exceptions' configurations",
see attached.
Grüße
Thomas
> @@ -0,0 +1,36 @@
> +// { dg-do run { target c++26 } }
> +
> +#include <span>
> +#include <stdexcept>
> +#include <testsuite_hooks.h>
> +
> +void
> +test_at()
> +{
> + int arr[4]{0, 1, 2, 3};
> + std::span<int> s(arr);
> + VERIFY(s.at(2) == 2);
> +#if __cpp_exceptions
> + try {
> + s.at(4); // { dg-warning "ignoring return value" }
> + VERIFY(false);
> + } catch (const std::out_of_range&) {
> + }
> +#endif
> +
> + auto s2 = s.subspan(1, 2);
> + VERIFY(s2.at(0) == 1);
> + VERIFY(s2.at(1) == 2);
> +#if __cpp_exceptions
> + try {
> + s2.at(2); // { dg-warning "ignoring return value" }
> + VERIFY(false);
> + } catch (const std::out_of_range&) {
> + }
> +#endif
> +}
> +
> +int main()
> +{
> + test_at();
> +}
-----------------
Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955
From 762b428815d4e762abdff5c1ffc1e9aa60da7870 Mon Sep 17 00:00:00 2001
From: Thomas Schwinge <thomas@codesourcery.com>
Date: Tue, 28 Nov 2023 17:30:13 +0100
Subject: [PATCH] Fix '23_containers/span/at.cc' for '-fno-exceptions'
configurations
Added in recent commit 1fa85dcf656e2f2c7e483c9ed3c2680bf7db6858
"libstdc++: Add std::span::at for C++26 (P2821R5)", the test case already
does use '#if __cpp_exceptions', but failed to correspondingly guard the
'dg-warning' directives, resulting in:
FAIL: 23_containers/span/at.cc -std=gnu++26 (test for warnings, line 15)
FAIL: 23_containers/span/at.cc -std=gnu++26 (test for warnings, line 26)
PASS: 23_containers/span/at.cc -std=gnu++26 (test for excess errors)
PASS: 23_containers/span/at.cc -std=gnu++26 execution test
libstdc++-v3/
* testsuite/23_containers/span/at.cc: Fix for '-fno-exceptions'
configurations.
---
libstdc++-v3/testsuite/23_containers/span/at.cc | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
@@ -12,7 +12,7 @@ test_at()
VERIFY(s.at(2) == 2);
#if __cpp_exceptions
try {
- s.at(4); // { dg-warning "ignoring return value" }
+ s.at(4); // { dg-warning "ignoring return value" "" { target exceptions_enabled } }
VERIFY(false);
} catch (const std::out_of_range&) {
}
@@ -23,7 +23,7 @@ test_at()
VERIFY(s2.at(1) == 2);
#if __cpp_exceptions
try {
- s2.at(2); // { dg-warning "ignoring return value" }
+ s2.at(2); // { dg-warning "ignoring return value" "" { target exceptions_enabled } }
VERIFY(false);
} catch (const std::out_of_range&) {
}
--
2.34.1