https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87683
--- Comment #1 from Sebastian Huber <sebastian.hu...@embedded-brains.de> --- It seems it has nothing to do with the non-null attribute. This function void d(void) { int s; void *p; s = posix_memalign(&p, 16, 16); if (s != 22) { a(); } else { b(); } } is optimized to: d: .LFB1: .cfi_startproc subq $24, %rsp .cfi_def_cfa_offset 32 movl $16, %edx movl $16, %esi leaq 8(%rsp), %rdi call posix_memalign addq $24, %rsp .cfi_def_cfa_offset 8 jmp a .cfi_endproc .LFE1: .size d, .-d Why does GCC assume that s != 22? Memory allocation may fail, in this case posix_memalign() may return ENOMEM which could be 22.