From ce01e2e64c340dadb55a8a24c545a13e654804d4 Mon Sep 17 00:00:00 2001 From: Jonathan Wakely Date: Wed, 22 Sep 2021 11:58:20 +0100 Subject: 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 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. --- .../testsuite/19_diagnostics/error_category/102425.cc | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 libstdc++-v3/testsuite/19_diagnostics/error_category/102425.cc (limited to 'libstdc++-v3/testsuite/19_diagnostics') 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 +#include + +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(); +} -- cgit v1.2.1