From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id A8C78386197D; Mon, 21 Dec 2020 10:33:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A8C78386197D From: "pault at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/98408] Character lengths for allocatable character arrays Date: Mon, 21 Dec 2020 10:33:51 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: fortran X-Bugzilla-Version: 11.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: pault at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 21 Dec 2020 10:33:51 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D98408 Paul Thomas changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |pault at gcc dot gnu.org --- Comment #1 from Paul Thomas --- Hi Thomas, >>From gfc_conv_intrinsic_sizeof: if (arg->ts.type =3D=3D BT_CHARACTER) byte_size =3D size_of_string_in_bytes (arg->ts.kind, argse.string_length); else { if (arg->rank =3D=3D 0) byte_size =3D TREE_TYPE (build_fold_indirect_ref_loc (input_loc= ation, argse.expr)= ); else byte_size =3D gfc_get_element_type (TREE_TYPE (argse.expr)); byte_size =3D 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 perh= aps void if TYPE_STRING_FLAG is not set) because of the cast in the allocation: a.data =3D (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=