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.