From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 74FDC3858C2F; Wed, 26 Jul 2023 20:17:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 74FDC3858C2F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1690402627; bh=0390NC4N/d2JLwlVZmPRgxPEsvhixzkzai9TfZnTJOw=; h=From:To:Subject:Date:From; b=DSTKp3Wopu2huV9QjUcyz1b+9WT5L7nMedqcR3MbKQTs4J7Mv4uQay0TVy2+T8/Ow JjDn9BVvMJTfrvxSXPsQOIk/T0pG7e5YK2E+X8HNZTwJuHfxBqzHxQInKON0IshLNV ZrThmFVHGA314s46bp7Xo10MdcbsR28K4T80ejzM= From: "kargl at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/110825] New: TYPE(*) dummy argument to generate an unused hidden argument Date: Wed, 26 Jul 2023 20:17:07 +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: 14.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: kargl 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: 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=3D110825 Bug ID: 110825 Summary: TYPE(*) dummy argument to generate an unused hidden argument Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: kargl at gcc dot gnu.org Target Milestone: --- The was pointed out in Fortran Discourse, https://fortran-lang.discourse.group/t/strange-behaviour-when-using-type-an= d-character-in-gfortran/6233 that gfortran generates wrong code for a valid program. Here's a slightly modified version of the program. program foo implicit none character(100) :: not_used call sub(not_used, "123") contains subroutine sub(useless_var, print_this) type(*), intent(in) :: useless_var character(*), intent(in) :: print_this if (len_trim(print_this) /=3D 3) stop 1 end subroutine sub end The subroutine reference in the main program is generating a call with two hidden arguments. From -fdump-tree-original,=20 void MAIN__ () { static void sub (void * & restrict, character(kind=3D1)[1:] & restrict, integer(kind=3D8)); character(kind=3D1) not_used[1:100]; sub (¬_used, &"123"[1]{lb: 1 sz: 1}, 100, 3); } we have hidden arguments 100 and 3. However, the code generated for the contained subroutine is only expecting one hidden argument. __attribute__((fn spec (". r r "))) void sub (void * & restrict useless_var, character(kind=3D1)[1:_print_this] & restrict print_this, integer(kind=3D8) _print_this) { ... } Thus, when compiled and executed the program hits 'STOP 1'. Likely, gfortr= an needs to add a possibly unused hidden argument to the argument list for a TYPE(*) dummy argument.=