From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 64E873858C3A; Wed, 6 Sep 2023 11:14:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 64E873858C3A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1693998882; bh=8bS1Px1wFbYbU3aPFmpFs0MX218E6r/1wErA0m8S9TM=; h=From:To:Subject:Date:From; b=awFMcEd2u0xMO9HGas2HbhbgVOI1tXXxPFkw1PQWJK8yHfOfX9+8lsWSqnqT4Brit HsADh7uWLpwawkZsJ8zsPeqz+YmsStEXPUD1iAoaSQfuPtUXUSVTtqA00/7GZSxsKN yp+B6Lrc7x02lmyyX3zMYBK3olm3uB3XbYfYyJZE= From: "mailling-lists-bd at posteo dot de" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/111304] New: Problem when passing implicit arrays of characters to functions Date: Wed, 06 Sep 2023 11:14:41 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: fortran X-Bugzilla-Version: 13.2.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: mailling-lists-bd at posteo dot de 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: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: 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=3D111304 Bug ID: 111304 Summary: Problem when passing implicit arrays of characters to functions Product: gcc Version: 13.2.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: mailling-lists-bd at posteo dot de Target Milestone: --- Hi, In the following code, the first call to `func1` works as expected and prin= ts the content of the array `my_directory`, while the second call, with the ar= ray defined directly in the function argument, leads to SIGABRT and prints=20 ``` ARRAY =3D my_directory/file1my_directory/file2my_directory/dum1 my_directory/dum2 corrupted size vs. prev_size ``` I have tested with gfortran 13.2.1 (gfortran -o test program.f90), on Fedora 38. It should also be noticed that both function calls run fine if we remove the `trim(prefix)//` from each character string. ``` program test implicit none character(len=3D256) :: test_array(4) character(len=3D:), allocatable :: prefix integer :: res prefix =3D 'my_directory' test_array =3D [ character(len=3D256) :: & & trim(prefix)//'/file1', & & trim(prefix)//'/file2', & & trim(prefix)//'/dum1', & & trim(prefix)//'/dum2' & & ] print *, 'Test with "res =3D func1(test_array)"' res =3D func1(test_array) print *, 'Test with "res =3D func1([ character(len=3D) :: ...] )"' res =3D func1([ character(len=3D256) :: & & trim(prefix)//'/file1', & & trim(prefix)//'/file2', & & trim(prefix)//'/dum1', & & trim(prefix)//'/dum2' & & ]) contains function func1(array) result(res) character(len=3D*), intent(in) :: array(:) integer :: res print *, 'ARRAY =3D ', array res =3D 0 end function func1 end program test ```=