https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81166
Bug ID: 81166 Summary: no need to check if the pointer you pass to free is NULL Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: izaberina at gmail dot com Target Milestone: --- gcc -Os compiles this function void myfree(void *mem) { if (mem) free(mem); } to myfree(void*): test rdi, rdi je .L1 jmp free .L1: ret why is that test not removed? free(NULL) is valid and a no op