* [committed] libstdc++: std::system_category should know meaning of zero [PR102425]
@ 2021-09-23 15:09 Jonathan Wakely
0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Wakely @ 2021-09-23 15:09 UTC (permalink / raw)
To: libstdc++, gcc-patches
[-- Attachment #1: Type: text/plain, Size: 434 bytes --]
Although 0 is not an errno value, it should still be recognized as
corresponding to a value belonging to the generic_category().
Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
libstdc++-v3/ChangeLog:
PR libstdc++/102425
* src/c++11/system_error.cc
(system_error_category::default_error_condition): Add 0 to
switch.
* testsuite/19_diagnostics/error_category/102425.cc: New test.
Tested x86_64-linux. Committed to trunk.
[-- Attachment #2: patch.txt --]
[-- Type: text/plain, Size: 2167 bytes --]
commit ce01e2e64c340dadb55a8a24c545a13e654804d4
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Wed Sep 22 11:58:20 2021
libstdc++: std::system_category should know meaning of zero [PR102425]
Although 0 is not an errno value, it should still be recognized as
corresponding to a value belonging to the generic_category().
Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
libstdc++-v3/ChangeLog:
PR libstdc++/102425
* src/c++11/system_error.cc
(system_error_category::default_error_condition): Add 0 to
switch.
* testsuite/19_diagnostics/error_category/102425.cc: New test.
diff --git a/libstdc++-v3/src/c++11/system_error.cc b/libstdc++-v3/src/c++11/system_error.cc
index f12290adaee..6c79202eb0e 100644
--- a/libstdc++-v3/src/c++11/system_error.cc
+++ b/libstdc++-v3/src/c++11/system_error.cc
@@ -70,6 +70,8 @@ namespace
virtual std::error_condition
default_error_condition(int ev) const noexcept
{
+ // Use generic category for all known POSIX errno values (including zero)
+ // and system category otherwise.
switch (ev)
{
// List of errno macros from [cerrno.syn].
@@ -310,6 +312,7 @@ namespace
#ifdef EXDEV
case EXDEV:
#endif
+ case 0:
return std::error_condition(ev, std::generic_category());
/* Additional system-dependent mappings from non-standard error codes
diff --git a/libstdc++-v3/testsuite/19_diagnostics/error_category/102425.cc b/libstdc++-v3/testsuite/19_diagnostics/error_category/102425.cc
new file mode 100644
index 00000000000..069b5e284e1
--- /dev/null
+++ b/libstdc++-v3/testsuite/19_diagnostics/error_category/102425.cc
@@ -0,0 +1,18 @@
+// { dg-do run { target c++11 } }
+#include <system_error>
+#include <testsuite_hooks.h>
+
+void test01()
+{
+ // PR libstdc++/102425
+ VERIFY( std::error_code() == std::error_condition() );
+
+ auto zero = std::system_category().default_error_condition(0);
+ // This is the condition that the equality above relies on:
+ VERIFY( zero.category() == std::generic_category() );
+}
+
+int main()
+{
+ test01();
+}
^ permalink raw reply [flat|nested] 2+ messages in thread
* [committed] libstdc++: std::system_category should know meaning of zero [PR102425]
@ 2021-09-23 15:08 Jonathan Wakely
0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Wakely @ 2021-09-23 15:08 UTC (permalink / raw)
To: libstdc++, gcc-patches
[-- Attachment #1: Type: text/plain, Size: 659 bytes --]
Although 0 is not an errno value, it should still be recognized as
corresponding to a value belonging to the generic_category().
Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
libstdc++-v3/ChangeLog:
PR libstdc++/102425
* src/c++11/system_error.cc
(system_error_category::default_error_condition): Add 0 to
switch.
* testsuite/19_diagnostics/error_category/102425.cc: New test.
Tested powerpc64le-linux. Committed to trunk.
git mailpatch dd396a321be5099536af36e64454c1fcf9d67e12
git mailpatch 477897451e46d67acb46f3ac45585e6eb9e7dde5
git mailpatch 8fa90926e08950cc00d0e22eace27402b9f9fa57
git mailpatch 43358e91bd1d2b376ce8f426cf9becedf8343a06
[-- Attachment #2: patch.txt --]
[-- Type: text/plain, Size: 2167 bytes --]
commit ce01e2e64c340dadb55a8a24c545a13e654804d4
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Wed Sep 22 11:58:20 2021
libstdc++: std::system_category should know meaning of zero [PR102425]
Although 0 is not an errno value, it should still be recognized as
corresponding to a value belonging to the generic_category().
Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
libstdc++-v3/ChangeLog:
PR libstdc++/102425
* src/c++11/system_error.cc
(system_error_category::default_error_condition): Add 0 to
switch.
* testsuite/19_diagnostics/error_category/102425.cc: New test.
diff --git a/libstdc++-v3/src/c++11/system_error.cc b/libstdc++-v3/src/c++11/system_error.cc
index f12290adaee..6c79202eb0e 100644
--- a/libstdc++-v3/src/c++11/system_error.cc
+++ b/libstdc++-v3/src/c++11/system_error.cc
@@ -70,6 +70,8 @@ namespace
virtual std::error_condition
default_error_condition(int ev) const noexcept
{
+ // Use generic category for all known POSIX errno values (including zero)
+ // and system category otherwise.
switch (ev)
{
// List of errno macros from [cerrno.syn].
@@ -310,6 +312,7 @@ namespace
#ifdef EXDEV
case EXDEV:
#endif
+ case 0:
return std::error_condition(ev, std::generic_category());
/* Additional system-dependent mappings from non-standard error codes
diff --git a/libstdc++-v3/testsuite/19_diagnostics/error_category/102425.cc b/libstdc++-v3/testsuite/19_diagnostics/error_category/102425.cc
new file mode 100644
index 00000000000..069b5e284e1
--- /dev/null
+++ b/libstdc++-v3/testsuite/19_diagnostics/error_category/102425.cc
@@ -0,0 +1,18 @@
+// { dg-do run { target c++11 } }
+#include <system_error>
+#include <testsuite_hooks.h>
+
+void test01()
+{
+ // PR libstdc++/102425
+ VERIFY( std::error_code() == std::error_condition() );
+
+ auto zero = std::system_category().default_error_condition(0);
+ // This is the condition that the equality above relies on:
+ VERIFY( zero.category() == std::generic_category() );
+}
+
+int main()
+{
+ test01();
+}
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-09-23 15:09 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-23 15:09 [committed] libstdc++: std::system_category should know meaning of zero [PR102425] Jonathan Wakely
-- strict thread matches above, loose matches on Subject: below --
2021-09-23 15:08 Jonathan Wakely
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).