From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 2BCDA38618C3; Mon, 16 Nov 2020 20:33:17 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2BCDA38618C3 From: "everythingfunctional at protonmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/97864] New: Homebrew Operator Overload ICE Date: Mon, 16 Nov 2020 20:33:17 +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: 10.2.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: everythingfunctional at protonmail dot com 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: Mon, 16 Nov 2020 20:33:17 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D97864 Bug ID: 97864 Summary: Homebrew Operator Overload ICE Product: gcc Version: 10.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: everythingfunctional at protonmail dot com Target Milestone: --- I have a project that was building fine on linux, but when I switched to Ma= cOS and tried to build, I got an ICE. I was able to narrow it down to the opera= tor overload. I'm completely baffled as to why this would build and run just fi= ne on linux, but cause an ICE on MacOS. Version info: GNU Fortran (Homebrew GCC 10.2.0) 10.2.0 Copyright (C) 2020 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. MWE (this could probably be simplified a bit more, but this seemed far enou= gh): module string_m implicit none private type, public :: VARYING_STRING private character(len=3D1), allocatable :: characters(:) end type interface operator(=3D=3D) module procedure character_EQ_String module procedure string_EQ_String end interface interface CHAR module procedure stringToChar end interface public :: & operator(=3D=3D), & CHAR, & VAR_STR contains elemental function character_EQ_String(lhs, rhs) result(equals) character(len=3D*), intent(in) :: lhs type(VARYING_STRING), intent(in) :: rhs logical :: equals equals =3D lhs =3D=3D char(rhs) end function character_EQ_String elemental function string_EQ_String(lhs, rhs) result(equals) type(VARYING_STRING), intent(in) :: lhs type(VARYING_STRING), intent(in) :: rhs logical :: equals equals =3D char(lhs) =3D=3D char(rhs) end function pure function stringToChar(string) result(chars) type(VARYING_STRING), intent(in) :: string character(len=3Dsize(string%characters)) :: chars integer :: i integer :: length_input integer :: length_output length_output =3D len(chars) if (allocated(string%characters)) then length_input =3D size(string%characters) do concurrent (i =3D 1 : min(length_input, length_output)) chars(i:i) =3D string%characters(i) end do if (length_input < length_output) then do concurrent (i =3D length_input+1 : length_output) chars(i:i) =3D " " end do end if else do concurrent (i =3D 1 : length_output) chars(i:i) =3D " " end do end if end function stringToChar elemental function VAR_STR(char) character(len=3D*), intent(in) :: char type(VARYING_STRING) :: VAR_STR integer :: i integer :: length length =3D len(char) allocate(VAR_STR%characters(length)) do concurrent (i =3D 1 : length) VAR_STR%characters(i) =3D char(i:i) end do end function VAR_STR end module module equal_test use string_m, only: VARYING_STRING, operator(=3D=3D), char implicit none private public :: do_compare contains pure function do_compare(first, second) result(result_) type(VARYING_STRING), intent(in) :: first type(VARYING_STRING), intent(in) :: second logical :: result_ result_ =3D char(first) =3D=3D char(second) ! works result_ =3D first =3D=3D second ! works ! result_ =3D char(first) =3D=3D second ! causes ice end function end module program main use equal_test, only: do_compare use string_m, only: var_str implicit none print *, do_compare(var_str("Hello"), var_str("World")) end program main=