C++ Logo


Advanced search

[cfenv] Question about C++'s std::fexcept_t vs C's fexcept_t

From: Sam Elliott <Archibald.Elliott_at_[hidden]>
Date: Mon, 13 Mar 2023 13:49:02 +0000
I have noticed a discrepancy between the C++ standard's description of `<cfenv>` and the C standard's description of <fenv.h>:

Specifically, in the current C++ working draft: https://eel.is/c++draft/cfenv, `std::fexcept_t` is denoted as being of "integer type", but the C standards I could find only say: "The type fexcept_t represents the floating-point status flags collectively, including any status the implementation associates with the flags", which by my reading doesn't require the type to be of integer type.

I'm not sure where the discrepancy has come from in this case. Is there some history I'm missing for the C++ definition of `std::fexcept_t`, which might explain the discrepancy?

A colleague pointed to some places where C++ has called out where it has added additional requirements to what C requires, for instance the C++ standard for `<cerrno>` [errno] paragraph 1 specifically calls out that "errno shall be defined as a macro", something that the POSIX <errno.h> header (itself based on the C <errno.h>) doesn't require - https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/errno.h.html<https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/errno.h.html#tag_13_10> - (I realise this case is odd, because C does say suppressing the macro is Undefined Behaviour).

I am preparing a formal Defect Report on the issue, because the C library in the toolchain I work on has an `fexcept_t` that is not of integer type.

IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.

Received on 2023-03-13 13:49:23