https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90370

--- Comment #4 from Florian Weimer <fw at gcc dot gnu.org> ---
(In reply to Jonathan Wakely from comment #3)
> The issue is basically that the C++ Standard Library defines two categories
> for error numbers known to the implementation: "generic" and "system", where
> the former is for the POSIX errno values, and the latter is for other error
> numbers used by the OS for other kinds of errors that aren't covered by a
> POSIX errno macro (which might be other non-standard EBLAH macros that the
> OS adds to the POSIX ones, or some totally different error numbers used by
> the OS, e.g. Windows has its own error numbers unrelated to errno). The
> question is which category zero belongs to.

This is really confusing for native POSIX systems because the generic/system
terminology appears to be swapped for them.  This is also reflected in the
standard:

<http://eel.is/c++draft/syserr.errcat.objects#4>

And in the documentation:

<https://en.cppreference.com/w/cpp/error/system_category>

With this observation in mind, I reach this conclusion:

For a native POSIX system, no translation of errno values is needed.  That
suggests to me that all int values (the ev argument) correspond to a POSIX
errno value, and therefore all error conditions crated by
default_­error_­condition should be of the system_category category.

> So although zero isn't a POSIX errno value, POSIX does "reserve" the value
> zero and give it special meaning (it's the value that won't get set to
> report an error). No posix-ish OS is going to give it a different meaning
> that clashes with that.

I'm not sure if this matters.  A non-POSIX systems can use 0 for a real error
code that needs to be mapped to an actual C/POSIX E* value (such ERANGE).

Reply via email to