>@@ -11413,8 +11429,10 @@ string_constant (tree arg, tree *ptr_offset) > 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)); >+ unsigned HOST_WIDE_INT charsize >+ = tree_to_uhwi (TYPE_SIZE_UNIT (TREE_TYPE (TREE_TYPE (init)))); >+ unsigned HOST_WIDE_INT length = TREE_STRING_LENGTH (init); >+ length = string_length (TREE_STRING_POINTER (init), charsize, length); > if (compare_tree_int (array_size, length + 1) < 0) > return NULL_TREE;
But TREE_STRING_LENGTH is the length in bytes including NUL-termination. then length is passed to string_length with expects it in units of charsize. and returns number of characters. then compare_tree_int compares array_size which is in units of bytes, but not the size of the innermost enclosing array. I really don't see why we need to support wide characters especially when there is no reasonable test coverage, and no usable wstrlen builtin first. Bernd.