https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86532
--- Comment #11 from Bernd Edlinger <bernd.edlinger at hotmail dot de> --- But seriously: /* Avoid returning a string that doesn't fit in the array it is stored in, like const char a[4] = "abcde"; but do handle those that fit even if they have excess initializers, such as in const char a[4] = "abc\000\000"; The excess elements contribute to TREE_STRING_LENGTH() but not to strlen(). */ unsigned HOST_WIDE_INT length = strnlen (TREE_STRING_POINTER (init), TREE_STRING_LENGTH (init)); if (compare_tree_int (array_size, length + 1) < 0) return NULL_TREE; this is supposed to prevent such optimizations, however it looks like the ARRAY_REFs decay in later optimization stages, so here it looks like the access is for an array[6] at offset 0 with an inital value of length 3.