From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 736D53858C66; Wed, 7 Feb 2024 19:35:15 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 736D53858C66 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1707334515; bh=QiDAYzqkz7tO5PV7AG2S24vpzHi7A3Ucuo0BvnsC7VA=; h=From:To:Subject:Date:In-Reply-To:References:From; b=vODejwq3XbQy0ILXXKbCubD8nCjv6Gas2mz2LBhmlePrPtu1HtZ43ps3sWNKghjR8 KH4ikNshqjtx3QRbnC8CX8PZBrc9K5tGgVkqRgR6jCVQ/lAcGQYdv5kknhcEB53X0x jl0Hrfflr6AfDhgI+/KM9CAVIGbrfIQvYdj2EnOM= From: "anlauf at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/113793] malloc abort on character allocate with source argument Date: Wed, 07 Feb 2024 19:35:15 +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: unknown 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: cc everconfirmed cf_reconfirmed_on keywords bug_status 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=3D113793 anlauf at gcc dot gnu.org changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |anlauf at gcc dot gnu.org Ever confirmed|0 |1 Last reconfirmed| |2024-02-07 Keywords| |wrong-code Status|UNCONFIRMED |NEW --- Comment #1 from anlauf at gcc dot gnu.org --- (In reply to Manfred Schwarb from comment #0) > Allocating an allocatable character array, I get a malloc error > when the source argument is not properly padded: >=20 > CHARACTER*30,allocatable :: a(:),b(:) > ALLOCATE(a(100),source=3D" ") > ALLOCATE(b(100),source=3D" ") > END >=20 > yields: > malloc(): corrupted top size Confirmed. > I would have expected that the source argument is automatically padded > as with variable assignments and function call arguments. The dump-tree shows that it is padded, but the actual malloc is too short: a.data =3D (void * restrict) __builtin_malloc (100); Omitting the source=3D part, we get the expected: a.data =3D (void * restrict) __builtin_malloc (3000);=