https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119575
Bug ID: 119575 Summary: ICE parsing expression with overloaded operators Product: gcc Version: 14.2.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: rnhmjoj at eurofusion dot eu Target Milestone: --- Compiling this program: 1 module myint_mod 2 3 type myint 4 integer :: n 5 contains 6 procedure :: add 7 generic, public :: operator(+) => add 8 end type 9 10 contains 11 12 pure function add(p, q) result(r) 13 class(myint), intent(in) :: p, q 14 class(myint), allocatable :: r 15 r = myint(p%n + q%n) 16 end function 17 18 end module myint_mod 19 20 program main 21 22 use myint_mod 23 24 type(myint) :: p, q 25 26 p = myint(3) 27 q = (p + p) 28 print *, q 29 30 end program results in the following error: f951: internal compiler error: Segmentation fault 0x1ee5e13 diagnostic_impl(rich_location*, diagnostic_metadata const*, int, char const*, __va_list_tag (*) [1], diagnostic_t) ???:0 0x1ee64f8 internal_error(char const*, ...) ???:0 0xe10d1f crash_signal(int) ???:0 0x77a9ea gfc_add_component_ref(gfc_expr*, char const*) ???:0 0x8347b5 gfc_resolve_code(gfc_code*, gfc_namespace*) ???:0 0x835aab resolve_codes(gfc_namespace*) ???:0 0x835b72 gfc_resolve(gfc_namespace*) [clone .part.0] ???:0 0x812e40 gfc_parse_file() ???:0 0x86f2ef gfc_be_parse_file() ???:0 I tested on GCC 13.3.0 and 14.2.1, both give the same error. Notes: 1. The program compiles and runs correctly after removing the parenthesis at line 27. 2. The same crash happens in ifort, but not ifx.