mirror of
https://gcc.gnu.org/git/gcc.git
synced 2024-12-25 03:55:32 +08:00
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.
This commit is contained in:
parent
f6a05b23cc
commit
ce01e2e64c
@ -70,6 +70,8 @@ namespace
|
|||||||
virtual std::error_condition
|
virtual std::error_condition
|
||||||
default_error_condition(int ev) const noexcept
|
default_error_condition(int ev) const noexcept
|
||||||
{
|
{
|
||||||
|
// Use generic category for all known POSIX errno values (including zero)
|
||||||
|
// and system category otherwise.
|
||||||
switch (ev)
|
switch (ev)
|
||||||
{
|
{
|
||||||
// List of errno macros from [cerrno.syn].
|
// List of errno macros from [cerrno.syn].
|
||||||
@ -310,6 +312,7 @@ namespace
|
|||||||
#ifdef EXDEV
|
#ifdef EXDEV
|
||||||
case EXDEV:
|
case EXDEV:
|
||||||
#endif
|
#endif
|
||||||
|
case 0:
|
||||||
return std::error_condition(ev, std::generic_category());
|
return std::error_condition(ev, std::generic_category());
|
||||||
|
|
||||||
/* Additional system-dependent mappings from non-standard error codes
|
/* Additional system-dependent mappings from non-standard error codes
|
||||||
|
@ -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();
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user