https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114952
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> --- Most likely GCC does not know errno is non-zero after the call to elf_open and checking `fd < 0`. Adding: if (ret == 0) __builtin_unreachable(); After the assignment of `ret = -errono;` fixes the warning.