GCC, standard library functions/builtins and POSIX conformance

Vincent Lefevre vincent+gcc@vinc17.org
Thu Jun 17 13:27:39 GMT 2021

The GCC manual says:

 If you need a Standard compliant library, then you need to find one, as
GCC does not provide one.  The GNU C library (called 'glibc') provides
ISO C, POSIX, BSD, SystemV and X/Open compatibility for GNU/Linux and
HURD-based GNU systems; no recent version of it supports other systems,
though some very old versions did.  Version 2.2 of the GNU C library
includes nearly complete C99 support.  You could also ask your operating
system vendor if newer libraries are available.

However, even if the GNU C library is used, GCC also provides some
builtins, and it is not clear whether when there is a difference
between ISO C and POSIX (e.g. an undefined behavior in C and some
defined behavior in POSIX), the GCC builtin just conforms to ISO C,
or also conforms to POSIX. So, IMHO, some clarification is needed.

An example is remquo(x,y,*quo) when y ≠ 0 and the result is NaN. ISO C
currently fails to define the behavior concerning *quo, making this call
undefined behavior. But in POSIX, this call is valid and *quo just takes
an (implicitly) unspecified value[*].

[*] https://austingroupbugs.net/view.php?id=713

Vincent Lefèvre <vincent@vinc17.net> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)

More information about the Gcc mailing list