https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70038
--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> --- (In reply to kenlon from comment #2) > call to stat with a null argument is not the matter,it will return -1,that > is ok. > the matter code is: > (prevlinkname ? "TRUE":"NULL"); > > if (prevlinkname) { > .... > } > > it will not judge "prevlinkname". No call to stat is the issue. Take the code you have: if (stat(prevlinkname, &stat_buf) == 0) { unlink(prevlinkname); } printf("%p %s\n",prevlinkname,(prevlinkname ? "TRUE":"NULL")); After the call to stat, GCC assumes prevlinkname is non null as it was an argument to stat; so it does "TRUE" branch of the comparison. Again calling stat with a NULL argument is undefined so GCC can assume all calls to stat have a non-null argument.