From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 217FF395569B; Tue, 1 Jun 2021 17:39:38 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 217FF395569B From: "thomas.robinson at noaa dot gov" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/100860] New: class(*) type is (character(*)) produces a segmentation fault when run Date: Tue, 01 Jun 2021 17:39:37 +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: 11.1.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: thomas.robinson at noaa dot gov 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 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: Tue, 01 Jun 2021 17:39:38 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D100860 Bug ID: 100860 Summary: class(*) type is (character(*)) produces a segmentation fault when run Product: gcc Version: 11.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: thomas.robinson at noaa dot gov Target Milestone: --- When a string is passed as an argument to a subroutine where the argument is `class(*)`, there is a seg fault when the type is selected. Other types se= em to be working. Previous versions of gfortran have no problem compiling and running this si= mple program. I think the code is correct. It seems to be gcc 11 that has an issue. Here is some test code: module ctest contains subroutine sub (carg, slen) class(*), intent (in) :: carg integer, optional, intent (in) :: slen select type (carg) type is (character(*)) if (.not.present(slen)) then write (6,*) "This is an error dealing with a string" else write (6,*) "string length is ",slen write (6,*) "String is ",carg(1:slen) endif type is (integer) write (6,*) "Integer type is ", carg type is (real) write (6,*) "Real type is ", carg class default write (6,*) "Not the right type" end select end subroutine sub end module ctest program test use ctest character (len=3D10) :: c10 character (len=3D:), allocatable :: sall integer :: i=3D100 real :: r =3D 999.9 logical :: l =3D .true. call sub (r) call sub (i) call sub (l) c10=3D"12345" allocate(character (len=3Di) :: sall) sall =3D "87654321" ! write (6,*) "c10=3D",trim(c10),"::LEN=3D",len_trim(c10) ! call sub(trim(c10), len_trim(c10)) write (6,*) "sall=3D",trim(sall),"::LEN=3D",len_trim(sall) call sub(trim(sall),len_trim(sall)) end program test Here is the output Real type is 999.900024=20=20=20=20 Integer type is 100 Not the right type sall=3D87654321::LEN=3D 8 Program received signal SIGSEGV: Segmentation fault - invalid memory refere= nce. I tried with heap and stack strings, and both fail (you can see I have the first one commented out). Please let me know if there's any more informati= on you need.=