From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 91A0E384B11C; Wed, 24 Apr 2024 19:47:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 91A0E384B11C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1713988073; bh=HCghZVrbp7kW4Y2tLj4rAVCC5Dpt13P/8Pe8i3F9xi4=; h=From:To:Subject:Date:In-Reply-To:References:From; b=mUMsYkjKWKq28KbE2mA5/naT/Hc0KD6x5DV19FcMfS/gY7kdZ/GowzGYQrZqQQV1+ jnEr5GGlx/ingzpaEo2XH9hMJDtecH38u5unauFSdognlhN6h6kKrO/Z3I7028ReWQ ViV9heYLT4r3vb+C7SuGP3XfRRnY3RYo0aKHCkpE= From: "anlauf at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/114827] Valgrind reports errors with class(*) assignment Date: Wed, 24 Apr 2024 19:47:53 +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: 13.2.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: anlauf at gcc dot gnu.org X-Bugzilla-Status: NEW 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: bug_status everconfirmed cf_reconfirmed_on keywords 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D114827 anlauf at gcc dot gnu.org changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Ever confirmed|0 |1 Last reconfirmed| |2024-04-24 Keywords| |wrong-code --- Comment #5 from anlauf at gcc dot gnu.org --- Confirmed. Two data points which give a hint what might be wrong: 1) the valgrind error count at runtime depends on the string length passed to foo. I get no errors for a string of length 1. 2) the dump-tree of subroutine foo looks suspicious: if (b->_data =3D=3D 0B) { b->_data =3D __builtin_malloc (MAX_EXPR <(unsigned long) rhs.1._vptr->_size, 1>); It looks like _size comes from: static struct __vtype_CHARACTER_1_ __vtab_CHARACTER_1_ =3D {._hash=3D8589= 3463, ._size=3D1, ._extends=3D0B, ._def_init=3D0B, ._copy=3D__copy_character_1, .= _final=3D0B}; and is always 1. On the other hand, subroutine run sets: class.2._vptr =3D (struct __vtype__STAR * {ref-all}) &__vtab_CHARACTER_1_; class.2._data =3D (void *) &"fubarfubarfubarfubarfubarfu"[1]{lb: 1 = sz: 1}; class.2._len =3D 27; but _len is used in foo for the _copy, but not for the allocation. Thus the size allocated needs to be fixed. Changing the character argument to use kind=3D4, I see that _size seems to represent the element size. The allocation size thus should be changed to (_size * _len). Need to find the place where this happens... Anyone?=