[Bug c/88576] -fno-math-errno causes GCC to consider that malloc does not set errno

aurelien at aurel32 dot net gcc-bugzilla@gcc.gnu.org
Sat Dec 22 18:01:00 GMT 2018


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

--- Comment #2 from Aurelien Jarno <aurelien at aurel32 dot net> ---
(In reply to Andrew Pinski from comment #1)
> IIRC malloc setting errno also non standard.

According to POSIX:

    The malloc() function shall fail if:

    [ENOMEM]
        [CX] [Option Start] Insufficient storage space is available. [Option
End]

In that case malloc returns a NULL pointer. However even after adding a check
for the return value, GCC still optimizes-out saving and restoring errno.


More information about the Gcc-bugs mailing list