http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58240
--- Comment #4 from Marc Glisse <glisse at gcc dot gnu.org> --- -fno-builtin (or some better such option)? strncmp is a standard function, your code redefining it has undefined behavior. gcc optimizes based on the standard behavior of the function.