https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98408
Paul Thomas <pault at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |pault at gcc dot gnu.org --- Comment #1 from Paul Thomas <pault at gcc dot gnu.org> --- Hi Thomas, >From gfc_conv_intrinsic_sizeof: if (arg->ts.type == BT_CHARACTER) byte_size = size_of_string_in_bytes (arg->ts.kind, argse.string_length); else { if (arg->rank == 0) byte_size = TREE_TYPE (build_fold_indirect_ref_loc (input_location, argse.expr)); else byte_size = gfc_get_element_type (TREE_TYPE (argse.expr)); byte_size = fold_convert (gfc_array_index_type, size_in_bytes (byte_size)); } } ie. characters are treated separately. The problem is that gfc_get_element_type will come back with void* (or perhaps void if TYPE_STRING_FLAG is not set) because of the cast in the allocation: a.data = (void * restrict) __builtin_malloc (50); which is what GFC_TYPE_ARRAY_DATAPTR_TYPE is coming back with. I think that you will have to either interrogate the dtype for the element length, use the span field or se->string_length if you know the kind. Not so much a bug as a 'feature', I'm afraid. Paul