public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "everythingfunctional at protonmail dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/97864] New: Homebrew Operator Overload ICE Date: Mon, 16 Nov 2020 20:33:17 +0000 [thread overview] Message-ID: <bug-97864-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97864 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 MacOS and tried to build, I got an ICE. I was able to narrow it down to the operator overload. I'm completely baffled as to why this would build and run just fine 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 enough): module string_m implicit none private type, public :: VARYING_STRING private character(len=1), allocatable :: characters(:) end type interface operator(==) module procedure character_EQ_String module procedure string_EQ_String end interface interface CHAR module procedure stringToChar end interface public :: & operator(==), & CHAR, & VAR_STR contains elemental function character_EQ_String(lhs, rhs) result(equals) character(len=*), intent(in) :: lhs type(VARYING_STRING), intent(in) :: rhs logical :: equals equals = lhs == 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 = char(lhs) == char(rhs) end function pure function stringToChar(string) result(chars) type(VARYING_STRING), intent(in) :: string character(len=size(string%characters)) :: chars integer :: i integer :: length_input integer :: length_output length_output = len(chars) if (allocated(string%characters)) then length_input = size(string%characters) do concurrent (i = 1 : min(length_input, length_output)) chars(i:i) = string%characters(i) end do if (length_input < length_output) then do concurrent (i = length_input+1 : length_output) chars(i:i) = " " end do end if else do concurrent (i = 1 : length_output) chars(i:i) = " " end do end if end function stringToChar elemental function VAR_STR(char) character(len=*), intent(in) :: char type(VARYING_STRING) :: VAR_STR integer :: i integer :: length length = len(char) allocate(VAR_STR%characters(length)) do concurrent (i = 1 : length) VAR_STR%characters(i) = char(i:i) end do end function VAR_STR end module module equal_test use string_m, only: VARYING_STRING, operator(==), 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_ = char(first) == char(second) ! works result_ = first == second ! works ! result_ = char(first) == 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
next reply other threads:[~2020-11-16 20:33 UTC|newest] Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-11-16 20:33 everythingfunctional at protonmail dot com [this message] 2020-11-16 23:02 ` [Bug fortran/97864] " dominiq at lps dot ens.fr 2020-11-17 5:57 ` everythingfunctional at protonmail dot com 2020-11-19 19:42 ` damian at sourceryinstitute dot org 2020-11-19 20:27 ` damian at sourceryinstitute dot org 2020-11-19 20:36 ` iains at gcc dot gnu.org 2020-11-19 20:49 ` everythingfunctional at protonmail dot com 2020-11-25 17:09 ` iains at gcc dot gnu.org 2020-11-25 20:05 ` everythingfunctional at protonmail dot com 2020-11-25 20:11 ` iains at gcc dot gnu.org 2020-11-25 20:26 ` fxcoudert at gcc dot gnu.org 2020-11-25 20:31 ` iains at gcc dot gnu.org 2020-11-25 20:35 ` fxcoudert at gcc dot gnu.org 2020-11-25 20:37 ` fxcoudert at gcc dot gnu.org 2020-11-25 20:43 ` iains at gcc dot gnu.org 2020-11-25 20:45 ` fxcoudert at gcc dot gnu.org 2020-11-26 1:09 ` iains at gcc dot gnu.org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-97864-4@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).