https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85310
--- Comment #6 from Dmitry Vyukov <dvyukov at google dot com> --- It seems to me that compiler is fine here and we just have a bug in kernel code. Result of strlen called on char[16] can't possibly by >15 (without causing undefined behavior -- reading past the end of the object -- in which case result and anything else does not matter). So the "if (res >= 16) res = 15" check is always a no-op and can be removed (for programs without undefined behavior). In this program strlen returns 32, but that's because the program contains undefined behavior -- you can't call strlen on non-zero-terminated objects.