Bug 118337 - [15 Regression] Fortran *.mod compatibility
Summary: [15 Regression] Fortran *.mod compatibility
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 15.0
: P1 normal
Target Milestone: 15.0
Assignee: Jakub Jelinek
URL:
Keywords: ABI, ice-on-invalid-code
Depends on:
Blocks:
 
Reported: 2025-01-07 18:47 UTC by Jakub Jelinek
Modified: 2025-01-10 09:30 UTC (History)
4 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2025-01-07 00:00:00


Attachments
libxc_master.f90 (409 bytes, text/plain)
2025-01-08 13:15 UTC, Jakub Jelinek
Details
fu.f90 (179 bytes, text/plain)
2025-01-08 13:15 UTC, Jakub Jelinek
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jakub Jelinek 2025-01-07 18:47:48 UTC
We are seeing weird ICEs when trunk gfortran consumes gfortran 14 produced *.mod files.
E.g.
f951: internal compiler error: in gfc_intrinsic_subroutine_by_id, at                                                                                                                  
fortran/intrinsic.cc:1069                                                                                                                                                             
Please submit a full bug report, with preprocessed source (by using                                                                                                                   
-freport-bug).                                                                                                                                                                        
when building elk and
internal compiler error: in gfc_trans_structure_assign, at                                                                                                                            
fortran/trans-expr.cc:9885                                                                                                                                                            
Please submit a full bug report, with preprocessed source (by using                                                                                                                   
-freport-bug).                                                                                                                                                                        
when building cp2k or OpenMolcas.
Now, I've reproduced it for OpenMolcas and it builds fine if I use xc_f03_lib_m.mod
built by gcc 15 and ICEs if I use xc_f03_lib_m.mod built by gcc 14 (both from libxc package).
The difference between the modules after zcat is
--- xc_f03_lib_m.14	2025-01-07 18:47:53.307400792 +0100
+++ xc_f03_lib_m.15	2025-01-07 18:47:44.155602052 +0100
@@ -647,12 +647,12 @@ UNKNOWN-PROC UNKNOWN IMPLICIT-SAVE 0 0)
 UNKNOWN UNKNOWN 0 0 IS_BIND_C IS_C_INTEROP PRIVATE_COMP) ((818 'c_address'
 (INTEGER 8 0 1 0 INTEGER ()) () () () (UNKNOWN-FL UNKNOWN-INTENT
 UNKNOWN-PROC UNKNOWN UNKNOWN 0 0) PRIVATE ())) PRIVATE (DERIVED 6 0 1 1
-VOID ()) 0 0 () () 0 () () () 2 42 0)
+VOID ()) 0 0 () () 0 () () () 2 63 0)
 10 'C_funptr' '__iso_c_binding' '' 1 ((DERIVED UNKNOWN-INTENT
 UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 IS_BIND_C IS_C_INTEROP PRIVATE_COMP) (
 (819 'c_address' (INTEGER 8 0 1 0 INTEGER ()) () () () (UNKNOWN-FL
 UNKNOWN-INTENT UNKNOWN-PROC UNKNOWN UNKNOWN 0 0) PRIVATE ())) PRIVATE (
-DERIVED 10 0 1 1 VOID ()) 0 0 () () 0 () () () 2 44 0)
+DERIVED 10 0 1 1 VOID ()) 0 0 () () 0 () () () 2 65 0)
 30 '__copy___iso_c_binding_C_funptr' 'xc_f03_lib_m' '' 820 ((PROCEDURE
 UNKNOWN-INTENT UNKNOWN-PROC DECL UNKNOWN 0 0 ARTIFICIAL SUBROUTINE
 ELEMENTAL PURE ALWAYS_EXPLICIT) () (UNKNOWN 0 0 0 0 UNKNOWN ()) 0 0 (
while it uses the same 
GFORTRAN module version '15' created from libxc_master.F90

I've tried to bisect where this change occurred, and used much simpler
module foo
  use, intrinsic :: iso_c_binding
  implicit none
  type :: bar
    private
    type(c_ptr) :: ptr = C_NULL_PTR
  end type bar
end module foo
for that.
I see 3 commits that changed the resulting foo.mod over the 15 development so far,
r15-4295, r15-6471 and r15-6615.
The r15-4294 to r15-4295 difference is after zcat
--- 1	2025-01-07 13:24:39.649273827 -0500
+++ 2	2025-01-07 13:24:42.949309056 -0500
@@ -23,12 +23,12 @@ INTEGER 8 0 0 1 UNKNOWN ()) 0 '0' ()) ()
 UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 IS_BIND_C IS_C_INTEROP PRIVATE_COMP) (
 (6 'c_address' (INTEGER 8 0 1 0 INTEGER ()) () () () (UNKNOWN-FL
 UNKNOWN-INTENT UNKNOWN-PROC UNKNOWN UNKNOWN 0 0) PRIVATE ())) PRIVATE (
-DERIVED 3 0 1 1 VOID ()) 0 0 () () 0 () () () 2 44 0)
+DERIVED 3 0 1 1 VOID ()) 0 0 () () 0 () () () 2 65 0)
 4 'C_ptr' '__iso_c_binding' '' 1 ((DERIVED UNKNOWN-INTENT UNKNOWN-PROC
 UNKNOWN UNKNOWN 0 0 IS_BIND_C IS_C_INTEROP PRIVATE_COMP) ((7 'c_address'
 (INTEGER 8 0 1 0 INTEGER ()) () () () (UNKNOWN-FL UNKNOWN-INTENT
 UNKNOWN-PROC UNKNOWN UNKNOWN 0 0) PRIVATE ())) PRIVATE (DERIVED 4 0 1 1
-VOID ()) 0 0 () () 0 () () () 2 42 0)
+VOID ()) 0 0 () () 0 () () () 2 63 0)
 8 '__def_init___iso_c_binding_C_funptr' 'foo' '' 1 ((VARIABLE
 UNKNOWN-INTENT UNKNOWN-PROC UNKNOWN IMPLICIT-SAVE 0 0 ARTIFICIAL TARGET)
 () (DERIVED 3 0 0 0 DERIVED ()) 0 0 () () 0 () () () 0 0)
@@ -119,76 +119,76 @@ UNKNOWN-ACCESS (UNKNOWN 0 0 0 0 UNKNOWN
 UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 IS_C_INTEROP IS_ISO_C) () (CHARACTER 1
 0 1 1 CHARACTER ((CONSTANT (INTEGER 8 0 0 0 INTEGER ()) 0 '1' ()))) 0 0
 () (CONSTANT (CHARACTER 1 0 1 1 UNKNOWN (())) 0 1 '\U00000007' ()) () 0
-() () () 2 35)
+() () () 2 56)
 44 'c_associated' '__iso_c_binding' '' 1 ((PROCEDURE UNKNOWN-INTENT
 UNKNOWN-PROC DECL UNKNOWN 0 0 INTRINSIC FUNCTION PURE) () (LOGICAL 4 0 0
-0 LOGICAL ()) 45 0 (46 47) () 0 () () () 2 48)
+0 LOGICAL ()) 45 0 (46 47) () 0 () () () 2 69)
 48 'c_backspace' '__iso_c_binding' '' 1 ((PARAMETER UNKNOWN-INTENT
 UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 IS_C_INTEROP IS_ISO_C) () (CHARACTER 1
 0 1 1 CHARACTER ((CONSTANT (INTEGER 8 0 0 0 INTEGER ()) 0 '1' ()))) 0 0
 () (CONSTANT (CHARACTER 1 0 1 1 UNKNOWN (())) 0 1 '\U00000008' ()) () 0
-() () () 2 36)
+() () () 2 57)
 49 'c_bool' '__iso_c_binding' '' 1 ((PARAMETER UNKNOWN-INTENT
 UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 IS_C_INTEROP IS_ISO_C) () (INTEGER 4 0
 1 1 LOGICAL ()) 0 0 () (CONSTANT (INTEGER 4 0 1 1 UNKNOWN ()) 0 '1' ())
-() 0 () () () 2 32)
+() 0 () () () 2 53)
 50 'c_carriage_return' '__iso_c_binding' '' 1 ((PARAMETER UNKNOWN-INTENT
 UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 IS_C_INTEROP IS_ISO_C) () (CHARACTER 1
 0 1 1 CHARACTER ((CONSTANT (INTEGER 8 0 0 0 INTEGER ()) 0 '1' ()))) 0 0
 () (CONSTANT (CHARACTER 1 0 1 1 UNKNOWN (())) 0 1 '\U0000000d' ()) () 0
-() () () 2 39)
+() () () 2 60)
 51 'c_char' '__iso_c_binding' '' 1 ((PARAMETER UNKNOWN-INTENT
 UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 IS_C_INTEROP IS_ISO_C) () (INTEGER 4 0
 1 1 CHARACTER ()) 0 0 () (CONSTANT (INTEGER 4 0 1 1 UNKNOWN ()) 0 '1' ())
-() 0 () () () 2 33)
+() 0 () () () 2 54)
 52 'c_double' '__iso_c_binding' '' 1 ((PARAMETER UNKNOWN-INTENT
 UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 IS_C_INTEROP IS_ISO_C) () (INTEGER 4 0
 1 1 REAL ()) 0 0 () (CONSTANT (INTEGER 4 0 1 1 UNKNOWN ()) 0 '8' ()) ()
-0 () () () 2 25)
+0 () () () 2 46)
 53 'c_double_complex' '__iso_c_binding' '' 1 ((PARAMETER UNKNOWN-INTENT
 UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 IS_C_INTEROP IS_ISO_C) () (INTEGER 4 0
 1 1 COMPLEX ()) 0 0 () (CONSTANT (INTEGER 4 0 1 1 UNKNOWN ()) 0 '8' ())
-() 0 () () () 2 29)
+() 0 () () () 2 50)
 54 'c_f_pointer' '__iso_c_binding' '' 1 ((PROCEDURE UNKNOWN-INTENT
 UNKNOWN-PROC DECL UNKNOWN 0 0 INTRINSIC SUBROUTINE) () (UNKNOWN 0 0 0 0
-UNKNOWN ()) 55 0 (56 57 58) () 0 () () () 2 46)
+UNKNOWN ()) 55 0 (56 57 58) () 0 () () () 2 67)
 59 'c_f_procpointer' '__iso_c_binding' '' 1 ((PROCEDURE UNKNOWN-INTENT
 UNKNOWN-PROC DECL UNKNOWN 0 0 INTRINSIC SUBROUTINE) () (UNKNOWN 0 0 0 0
-UNKNOWN ()) 60 0 (61 62) () 0 () () () 2 47)
+UNKNOWN ()) 60 0 (61 62) () 0 () () () 2 68)
 63 'c_float' '__iso_c_binding' '' 1 ((PARAMETER UNKNOWN-INTENT
 UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 IS_C_INTEROP IS_ISO_C) () (INTEGER 4 0
 1 1 REAL ()) 0 0 () (CONSTANT (INTEGER 4 0 1 1 UNKNOWN ()) 0 '4' ()) ()
-0 () () () 2 24)
+0 () () () 2 45)
 64 'c_float128' '__iso_c_binding' '' 1 ((PARAMETER UNKNOWN-INTENT
 UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 IS_C_INTEROP IS_ISO_C) () (INTEGER 4 0
 1 1 REAL ()) 0 0 () (CONSTANT (INTEGER 4 0 1 1 UNKNOWN ()) 0 '16' ()) ()
-0 () () () 2 27)
+0 () () () 2 48)
 65 'c_float128_complex' '__iso_c_binding' '' 1 ((PARAMETER
 UNKNOWN-INTENT UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 IS_C_INTEROP IS_ISO_C) ()
 (INTEGER 4 0 1 1 COMPLEX ()) 0 0 () (CONSTANT (INTEGER 4 0 1 1 UNKNOWN ())
-0 '16' ()) () 0 () () () 2 31)
+0 '16' ()) () 0 () () () 2 52)
 66 'c_float_complex' '__iso_c_binding' '' 1 ((PARAMETER UNKNOWN-INTENT
 UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 IS_C_INTEROP IS_ISO_C) () (INTEGER 4 0
 1 1 COMPLEX ()) 0 0 () (CONSTANT (INTEGER 4 0 1 1 UNKNOWN ()) 0 '4' ())
-() 0 () () () 2 28)
+() 0 () () () 2 49)
 67 'c_form_feed' '__iso_c_binding' '' 1 ((PARAMETER UNKNOWN-INTENT
 UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 IS_C_INTEROP IS_ISO_C) () (CHARACTER 1
 0 1 1 CHARACTER ((CONSTANT (INTEGER 8 0 0 0 INTEGER ()) 0 '1' ()))) 0 0
 () (CONSTANT (CHARACTER 1 0 1 1 UNKNOWN (())) 0 1 '\U0000000c' ()) () 0
-() () () 2 37)
+() () () 2 58)
 68 'c_funloc' '__iso_c_binding' '' 1 ((PROCEDURE UNKNOWN-INTENT
 UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 INTRINSIC FUNCTION
 ARRAY_OUTER_DEPENDENCY) () (DERIVED 3 0 1 0 DERIVED ()) 0 0 () () 0 () ()
-() 2 49)
+() 2 70)
 69 'c_funptr' '__iso_c_binding' '' 1 ((PROCEDURE UNKNOWN-INTENT
 UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 FUNCTION GENERIC IS_ISO_C
 ARRAY_OUTER_DEPENDENCY) () (UNKNOWN 0 0 0 0 UNKNOWN ()) 0 0 () () 0 () ()
-() 2 44)
+() 2 65)
 70 'c_horizontal_tab' '__iso_c_binding' '' 1 ((PARAMETER UNKNOWN-INTENT
 UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 IS_C_INTEROP IS_ISO_C) () (CHARACTER 1
 0 1 1 CHARACTER ((CONSTANT (INTEGER 8 0 0 0 INTEGER ()) 0 '1' ()))) 0 0
 () (CONSTANT (CHARACTER 1 0 1 1 UNKNOWN (())) 0 1 '\U00000009' ()) () 0
-() () () 2 40)
+() () () 2 61)
 71 'c_int' '__iso_c_binding' '' 1 ((PARAMETER UNKNOWN-INTENT
 UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 IS_C_INTEROP IS_ISO_C) () (INTEGER 4 0
 1 1 INTEGER ()) 0 0 () (CONSTANT (INTEGER 4 0 1 1 UNKNOWN ()) 0 '4' ())
@@ -264,7 +264,7 @@ UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 IS_C_IN
 89 'c_loc' '__iso_c_binding' '' 1 ((PROCEDURE UNKNOWN-INTENT
 UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 INTRINSIC FUNCTION
 ARRAY_OUTER_DEPENDENCY) () (DERIVED 4 0 1 0 DERIVED ()) 0 0 () () 0 () ()
-() 2 50)
+() 2 71)
 90 'c_long' '__iso_c_binding' '' 1 ((PARAMETER UNKNOWN-INTENT
 UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 IS_C_INTEROP IS_ISO_C) () (INTEGER 4 0
 1 1 INTEGER ()) 0 0 () (CONSTANT (INTEGER 4 0 1 1 UNKNOWN ()) 0 '8' ())
@@ -272,11 +272,11 @@ UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 IS_C_IN
 91 'c_long_double' '__iso_c_binding' '' 1 ((PARAMETER UNKNOWN-INTENT
 UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 IS_C_INTEROP IS_ISO_C) () (INTEGER 4 0
 1 1 REAL ()) 0 0 () (CONSTANT (INTEGER 4 0 1 1 UNKNOWN ()) 0 '10' ()) ()
-0 () () () 2 26)
+0 () () () 2 47)
 92 'c_long_double_complex' '__iso_c_binding' '' 1 ((PARAMETER
 UNKNOWN-INTENT UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 IS_C_INTEROP IS_ISO_C) ()
 (INTEGER 4 0 1 1 COMPLEX ()) 0 0 () (CONSTANT (INTEGER 4 0 1 1 UNKNOWN ())
-0 '10' ()) () 0 () () () 2 30)
+0 '10' ()) () 0 () () () 2 51)
 93 'c_long_long' '__iso_c_binding' '' 1 ((PARAMETER UNKNOWN-INTENT
 UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 IS_C_INTEROP IS_ISO_C) () (INTEGER 4 0
 1 1 INTEGER ()) 0 0 () (CONSTANT (INTEGER 4 0 1 1 UNKNOWN ()) 0 '8' ())
@@ -285,26 +285,26 @@ UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 IS_C_IN
 UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 IS_C_INTEROP IS_ISO_C) () (CHARACTER 1
 0 1 1 CHARACTER ((CONSTANT (INTEGER 8 0 0 0 INTEGER ()) 0 '1' ()))) 0 0
 () (CONSTANT (CHARACTER 1 0 1 1 UNKNOWN (())) 0 1 '\U0000000a' ()) () 0
-() () () 2 38)
+() () () 2 59)
 95 'c_null_char' '__iso_c_binding' '' 1 ((PARAMETER UNKNOWN-INTENT
 UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 IS_C_INTEROP IS_ISO_C) () (CHARACTER 1
 0 1 1 CHARACTER ((CONSTANT (INTEGER 8 0 0 0 INTEGER ()) 0 '1' ()))) 0 0
 () (CONSTANT (CHARACTER 1 0 1 1 UNKNOWN (())) 0 1 '\U00000000' ()) () 0
-() () () 2 34)
+() () () 2 55)
 96 'c_null_funptr' '__iso_c_binding' '' 1 ((PARAMETER UNKNOWN-INTENT
 UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 IS_BIND_C IS_C_INTEROP IS_ISO_C) () (
 DERIVED 3 0 1 1 VOID ()) 0 0 () (STRUCTURE (DERIVED 3 0 0 0 DERIVED ())
 0 (((CONSTANT (INTEGER 8 0 0 1 UNKNOWN ()) 0 '0' ()) ())) () ()) () 0 ()
-() () 2 45)
+() () 2 66)
 97 'c_null_ptr' '__iso_c_binding' '' 1 ((PARAMETER UNKNOWN-INTENT
 UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 IS_BIND_C IS_C_INTEROP IS_ISO_C) () (
 DERIVED 4 0 1 1 VOID ()) 0 0 () (STRUCTURE (DERIVED 4 0 0 0 DERIVED ())
 0 (((CONSTANT (INTEGER 8 0 0 1 UNKNOWN ()) 0 '0' ()) ())) () ()) () 0 ()
-() () 2 43)
+() () 2 64)
 98 'c_ptr' '__iso_c_binding' '' 1 ((PROCEDURE UNKNOWN-INTENT
 UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 FUNCTION GENERIC IS_ISO_C
 ARRAY_OUTER_DEPENDENCY) () (UNKNOWN 0 0 0 0 UNKNOWN ()) 0 0 () () 0 () ()
-() 2 42)
+() 2 63)
 99 'c_ptrdiff_t' '__iso_c_binding' '' 1 ((PARAMETER UNKNOWN-INTENT
 UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 IS_C_INTEROP IS_ISO_C) () (INTEGER 4 0
 1 1 INTEGER ()) 0 0 () (CONSTANT (INTEGER 4 0 1 1 UNKNOWN ()) 0 '8' ())
@@ -323,12 +323,12 @@ UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 IS_C_IN
 () 0 () () () 2 7)
 103 'c_sizeof' '__iso_c_binding' '' 1 ((PROCEDURE UNKNOWN-INTENT
 UNKNOWN-PROC DECL UNKNOWN 0 0 INTRINSIC FUNCTION PURE) () (INTEGER 8 0 0
-0 INTEGER ()) 104 0 (105) () 0 () () () 2 51)
+0 INTEGER ()) 104 0 (105) () 0 () () () 2 72)
 106 'c_vertical_tab' '__iso_c_binding' '' 1 ((PARAMETER UNKNOWN-INTENT
 UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 IS_C_INTEROP IS_ISO_C) () (CHARACTER 1
 0 1 1 CHARACTER ((CONSTANT (INTEGER 8 0 0 0 INTEGER ()) 0 '1' ()))) 0 0
 () (CONSTANT (CHARACTER 1 0 1 1 UNKNOWN (())) 0 1 '\U0000000b' ()) () 0
-() () () 2 41)
+() () () 2 62)
 107 'foo' 'foo' '' 1 ((MODULE UNKNOWN-INTENT UNKNOWN-PROC UNKNOWN
 UNKNOWN 0 0) () (UNKNOWN 0 0 0 0 UNKNOWN ()) 0 0 () () 0 () () () 0 0)
 23 '__copy___iso_c_binding_C_funptr' 'foo' '' 108 ((PROCEDURE

r15-6470 to r15-6471 difference is
--- 1	2025-01-07 13:39:26.994710159 -0500
+++ 2	2025-01-07 13:39:21.321649763 -0500
@@ -329,19 +329,22 @@ UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 IS_C_IN
 0 1 1 CHARACTER ((CONSTANT (INTEGER 8 0 0 0 INTEGER ()) 0 '1' ()))) 0 0
 () (CONSTANT (CHARACTER 1 0 1 1 UNKNOWN (())) 0 1 '\U0000000b' ()) () 0
 () () () 2 62)
-107 'foo' 'foo' '' 1 ((MODULE UNKNOWN-INTENT UNKNOWN-PROC UNKNOWN
+107 'f_c_string' '__iso_c_binding' '' 1 ((PROCEDURE UNKNOWN-INTENT
+UNKNOWN-PROC DECL UNKNOWN 0 0 INTRINSIC FUNCTION PURE) () (CHARACTER 1 0
+0 0 CHARACTER ()) 108 0 (109 110) () 0 () () () 2 73)
+111 'foo' 'foo' '' 1 ((MODULE UNKNOWN-INTENT UNKNOWN-PROC UNKNOWN
 UNKNOWN 0 0) () (UNKNOWN 0 0 0 0 UNKNOWN ()) 0 0 () () 0 () () () 0 0)
-23 '__copy___iso_c_binding_C_funptr' 'foo' '' 108 ((PROCEDURE
+23 '__copy___iso_c_binding_C_funptr' 'foo' '' 112 ((PROCEDURE
 UNKNOWN-INTENT UNKNOWN-PROC DECL UNKNOWN 0 0 ARTIFICIAL SUBROUTINE
 ELEMENTAL PURE ALWAYS_EXPLICIT) () (UNKNOWN 0 0 0 0 UNKNOWN ()) 0 0 (
-109 110) () 0 () () () 0 0)
-31 '__copy___iso_c_binding_C_ptr' 'foo' '' 111 ((PROCEDURE
+113 114) () 0 () () () 0 0)
+31 '__copy___iso_c_binding_C_ptr' 'foo' '' 115 ((PROCEDURE
 UNKNOWN-INTENT UNKNOWN-PROC DECL UNKNOWN 0 0 ARTIFICIAL SUBROUTINE
 ELEMENTAL PURE ALWAYS_EXPLICIT) () (UNKNOWN 0 0 0 0 UNKNOWN ()) 0 0 (
-112 113) () 0 () () () 0 0)
-39 '__copy_foo_Bar' 'foo' '' 114 ((PROCEDURE UNKNOWN-INTENT UNKNOWN-PROC
+116 117) () 0 () () () 0 0)
+39 '__copy_foo_Bar' 'foo' '' 118 ((PROCEDURE UNKNOWN-INTENT UNKNOWN-PROC
 DECL UNKNOWN 0 0 ARTIFICIAL SUBROUTINE ELEMENTAL PURE ALWAYS_EXPLICIT) ()
-(UNKNOWN 0 0 0 0 UNKNOWN ()) 0 0 (115 116) () 0 () () () 0 0)
+(UNKNOWN 0 0 0 0 UNKNOWN ()) 0 0 (119 120) () 0 () () () 0 0)
 46 'c_ptr_1' '' '' 45 ((VARIABLE IN UNKNOWN-PROC UNKNOWN UNKNOWN 0 0
 DUMMY) () (VOID 0 0 0 0 VOID ()) 0 0 () () 0 () () () 0 0)
 47 'c_ptr_2' '' '' 45 ((VARIABLE IN UNKNOWN-PROC UNKNOWN UNKNOWN 0 0
@@ -358,22 +361,27 @@ OPTIONAL DUMMY) () (INTEGER 4 0 0 0 INTE
 () (UNKNOWN 0 0 0 0 UNKNOWN ()) 0 0 () () 0 () () () 0 0)
 105 'x' '' '' 104 ((VARIABLE IN UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 DUMMY)
 () (UNKNOWN 0 0 0 0 UNKNOWN ()) 0 0 () () 0 () () () 0 0)
-109 'src' '' '' 108 ((VARIABLE IN UNKNOWN-PROC UNKNOWN UNKNOWN 0 0
+109 'string' '' '' 108 ((VARIABLE IN UNKNOWN-PROC UNKNOWN UNKNOWN 0 0
+DUMMY) () (CHARACTER 1 0 0 0 CHARACTER (())) 0 0 () () 0 () () () 0 0)
+110 'asis' '' '' 108 ((VARIABLE IN UNKNOWN-PROC UNKNOWN UNKNOWN 0 0
+OPTIONAL DUMMY) () (CHARACTER 1 0 0 0 CHARACTER (())) 0 0 () () 0 () ()
+() 0 0)
+113 'src' '' '' 112 ((VARIABLE IN UNKNOWN-PROC UNKNOWN UNKNOWN 0 0
 ARTIFICIAL DUMMY) () (DERIVED 3 0 0 0 DERIVED ()) 0 0 () () 0 () () () 0
 0)
-110 'dst' '' '' 108 ((VARIABLE INOUT UNKNOWN-PROC UNKNOWN UNKNOWN 0 0
+114 'dst' '' '' 112 ((VARIABLE INOUT UNKNOWN-PROC UNKNOWN UNKNOWN 0 0
 ARTIFICIAL DUMMY) () (DERIVED 3 0 0 0 DERIVED ()) 0 0 () () 0 () () () 0
 0)
-112 'src' '' '' 111 ((VARIABLE IN UNKNOWN-PROC UNKNOWN UNKNOWN 0 0
+116 'src' '' '' 115 ((VARIABLE IN UNKNOWN-PROC UNKNOWN UNKNOWN 0 0
 ARTIFICIAL DUMMY) () (DERIVED 4 0 0 0 DERIVED ()) 0 0 () () 0 () () () 0
 0)
-113 'dst' '' '' 111 ((VARIABLE INOUT UNKNOWN-PROC UNKNOWN UNKNOWN 0 0
+117 'dst' '' '' 115 ((VARIABLE INOUT UNKNOWN-PROC UNKNOWN UNKNOWN 0 0
 ARTIFICIAL DUMMY) () (DERIVED 4 0 0 0 DERIVED ()) 0 0 () () 0 () () () 0
 0)
-115 'src' '' '' 114 ((VARIABLE IN UNKNOWN-PROC UNKNOWN UNKNOWN 0 0
+119 'src' '' '' 118 ((VARIABLE IN UNKNOWN-PROC UNKNOWN UNKNOWN 0 0
 ARTIFICIAL DUMMY) () (DERIVED 2 0 0 0 DERIVED ()) 0 0 () () 0 () () () 0
 0)
-116 'dst' '' '' 114 ((VARIABLE INOUT UNKNOWN-PROC UNKNOWN UNKNOWN 0 0
+120 'dst' '' '' 118 ((VARIABLE INOUT UNKNOWN-PROC UNKNOWN UNKNOWN 0 0
 ARTIFICIAL DUMMY) () (DERIVED 2 0 0 0 DERIVED ()) 0 0 () () 0 () () () 0
 0)
 )
@@ -399,4 +407,5 @@ ARTIFICIAL DUMMY) () (DERIVED 2 0 0 0 DE
 'c_long_double_complex' 0 92 'c_long_long' 0 93 'c_new_line' 0 94
 'c_null_char' 0 95 'c_null_funptr' 0 96 'c_null_ptr' 0 97 'c_ptr' 0 98
 'c_ptrdiff_t' 0 99 'c_short' 0 100 'c_signed_char' 0 101 'c_size_t' 0
-102 'c_sizeof' 0 103 'c_vertical_tab' 0 106 'foo' 0 107)
+102 'c_sizeof' 0 103 'c_vertical_tab' 0 106 'f_c_string' 0 107 'foo' 0
+111)

and finally r15-6614 to r15-6615 difference is
--- 1	2025-01-07 13:40:19.903271399 -0500
+++ 2	2025-01-07 13:40:24.276317238 -0500
@@ -51,8 +51,8 @@ DERIVED ()) 0 0 () () 0 () () () 0 0)
 UNKNOWN IMPLICIT-SAVE 0 0 TARGET VTAB) () (DERIVED 17 0 0 0 DERIVED ())
 0 0 () () 0 () () () 0 0)
 13 '__vtype___iso_c_binding_C_funptr' 'foo' '' 1 ((DERIVED
-UNKNOWN-INTENT UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 VTYPE) ((18 '_hash' (
-INTEGER 4 0 0 0 INTEGER ()) () () () (UNKNOWN-FL UNKNOWN-INTENT
+UNKNOWN-INTENT UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 RECURSIVE VTYPE) ((18
+'_hash' (INTEGER 4 0 0 0 INTEGER ()) () () () (UNKNOWN-FL UNKNOWN-INTENT
 UNKNOWN-PROC UNKNOWN UNKNOWN 0 0) PRIVATE (CONSTANT (INTEGER 4 0 0 0
 INTEGER ()) 0 '0' ())) (19 '_size' (INTEGER 8 0 0 0 INTEGER ()) () () ()
 (UNKNOWN-FL UNKNOWN-INTENT UNKNOWN-PROC UNKNOWN UNKNOWN 0 0) PRIVATE) (
@@ -72,10 +72,10 @@ UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 SUBROUT
 UNKNOWN-ACCESS OVERRIDABLE PASS SPECIFIC PPC '' 0))) UNKNOWN-ACCESS (
 UNKNOWN 0 0 0 0 UNKNOWN ()) 0 0 () () 0 () () () 0 0 0)
 15 '__vtype___iso_c_binding_C_ptr' 'foo' '' 1 ((DERIVED UNKNOWN-INTENT
-UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 VTYPE) ((26 '_hash' (INTEGER 4 0 0 0
-INTEGER ()) () () () (UNKNOWN-FL UNKNOWN-INTENT UNKNOWN-PROC UNKNOWN
-UNKNOWN 0 0) PRIVATE (CONSTANT (INTEGER 4 0 0 0 INTEGER ()) 0 '0' ())) (
-27 '_size' (INTEGER 8 0 0 0 INTEGER ()) () () () (UNKNOWN-FL
+UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 RECURSIVE VTYPE) ((26 '_hash' (INTEGER
+4 0 0 0 INTEGER ()) () () () (UNKNOWN-FL UNKNOWN-INTENT UNKNOWN-PROC
+UNKNOWN UNKNOWN 0 0) PRIVATE (CONSTANT (INTEGER 4 0 0 0 INTEGER ()) 0 '0'
+())) (27 '_size' (INTEGER 8 0 0 0 INTEGER ()) () () () (UNKNOWN-FL
 UNKNOWN-INTENT UNKNOWN-PROC UNKNOWN UNKNOWN 0 0) PRIVATE) (28 '_extends'
 (DERIVED 15 0 0 0 DERIVED ()) () () () (UNKNOWN-FL UNKNOWN-INTENT
 UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 POINTER) PRIVATE) (29 '_def_init' (
@@ -93,25 +93,26 @@ UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 SUBROUT
 UNKNOWN-ACCESS OVERRIDABLE PASS SPECIFIC PPC '' 0))) UNKNOWN-ACCESS (
 UNKNOWN 0 0 0 0 UNKNOWN ()) 0 0 () () 0 () () () 0 0 0)
 17 '__vtype_foo_Bar' 'foo' '' 1 ((DERIVED UNKNOWN-INTENT UNKNOWN-PROC
-UNKNOWN UNKNOWN 0 0 VTYPE) ((34 '_hash' (INTEGER 4 0 0 0 INTEGER ()) ()
-() () (UNKNOWN-FL UNKNOWN-INTENT UNKNOWN-PROC UNKNOWN UNKNOWN 0 0)
-PRIVATE (CONSTANT (INTEGER 4 0 0 0 INTEGER ()) 0 '1511322' ())) (35
-'_size' (INTEGER 8 0 0 0 INTEGER ()) () () () (UNKNOWN-FL UNKNOWN-INTENT
-UNKNOWN-PROC UNKNOWN UNKNOWN 0 0) PRIVATE) (36 '_extends' (DERIVED 17 0
-0 0 DERIVED ()) () () () (UNKNOWN-FL UNKNOWN-INTENT UNKNOWN-PROC UNKNOWN
-UNKNOWN 0 0 POINTER) PRIVATE) (37 '_def_init' (DERIVED 2 0 0 0 DERIVED ())
-() () () (UNKNOWN-FL UNKNOWN-INTENT UNKNOWN-PROC UNKNOWN UNKNOWN 0 0
-ARTIFICIAL POINTER) PRIVATE) (38 '_copy' (UNKNOWN 0 39 0 0 UNKNOWN ()) ()
-() () (UNKNOWN-FL UNKNOWN-INTENT UNKNOWN-PROC UNKNOWN UNKNOWN 0 0
-SUBROUTINE ELEMENTAL PURE ALWAYS_EXPLICIT PROC_POINTER) PRIVATE (
-UNKNOWN-ACCESS OVERRIDABLE PASS SPECIFIC PPC '' 0)) (40 '_final' (
-UNKNOWN 0 0 0 0 UNKNOWN ()) () () () (UNKNOWN-FL UNKNOWN-INTENT
-UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 ARTIFICIAL PROC_POINTER) PRIVATE (NULL
-(UNKNOWN 0 0 0 0 UNKNOWN ()) 0 ()) (UNKNOWN-ACCESS OVERRIDABLE PASS
-SPECIFIC PPC '' 0)) (41 '_deallocate' (UNKNOWN 0 0 0 0 UNKNOWN ()) () ()
-() (PROCEDURE UNKNOWN-INTENT UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 SUBROUTINE
-PROC_POINTER) PRIVATE (UNKNOWN-ACCESS OVERRIDABLE PASS SPECIFIC PPC '' 0)))
-UNKNOWN-ACCESS (UNKNOWN 0 0 0 0 UNKNOWN ()) 0 0 () () 0 () () () 0 0 0)
+UNKNOWN UNKNOWN 0 0 RECURSIVE VTYPE) ((34 '_hash' (INTEGER 4 0 0 0
+INTEGER ()) () () () (UNKNOWN-FL UNKNOWN-INTENT UNKNOWN-PROC UNKNOWN
+UNKNOWN 0 0) PRIVATE (CONSTANT (INTEGER 4 0 0 0 INTEGER ()) 0 '1511322'
+())) (35 '_size' (INTEGER 8 0 0 0 INTEGER ()) () () () (UNKNOWN-FL
+UNKNOWN-INTENT UNKNOWN-PROC UNKNOWN UNKNOWN 0 0) PRIVATE) (36 '_extends'
+(DERIVED 17 0 0 0 DERIVED ()) () () () (UNKNOWN-FL UNKNOWN-INTENT
+UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 POINTER) PRIVATE) (37 '_def_init' (
+DERIVED 2 0 0 0 DERIVED ()) () () () (UNKNOWN-FL UNKNOWN-INTENT
+UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 ARTIFICIAL POINTER) PRIVATE) (38 '_copy'
+(UNKNOWN 0 39 0 0 UNKNOWN ()) () () () (UNKNOWN-FL UNKNOWN-INTENT
+UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 SUBROUTINE ELEMENTAL PURE
+ALWAYS_EXPLICIT PROC_POINTER) PRIVATE (UNKNOWN-ACCESS OVERRIDABLE PASS
+SPECIFIC PPC '' 0)) (40 '_final' (UNKNOWN 0 0 0 0 UNKNOWN ()) () () () (
+UNKNOWN-FL UNKNOWN-INTENT UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 ARTIFICIAL
+PROC_POINTER) PRIVATE (NULL (UNKNOWN 0 0 0 0 UNKNOWN ()) 0 ()) (
+UNKNOWN-ACCESS OVERRIDABLE PASS SPECIFIC PPC '' 0)) (41 '_deallocate' (
+UNKNOWN 0 0 0 0 UNKNOWN ()) () () () (PROCEDURE UNKNOWN-INTENT
+UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 SUBROUTINE PROC_POINTER) PRIVATE (
+UNKNOWN-ACCESS OVERRIDABLE PASS SPECIFIC PPC '' 0))) UNKNOWN-ACCESS (
+UNKNOWN 0 0 0 0 UNKNOWN ()) 0 0 () () 0 () () () 0 0 0)
 42 'bar' 'foo' '' 1 ((PROCEDURE UNKNOWN-INTENT UNKNOWN-PROC DECL UNKNOWN
 0 0 FUNCTION GENERIC) () (UNKNOWN 0 0 0 0 UNKNOWN ()) 0 0 () () 0 () ()
 () 0 0)

The difference in xc_f03_lib_m feels like the first one, i.e. r15-4295.
If I try to bisect
module baz
  use, intrinsic :: iso_c_binding
  implicit none
  private
  public :: qux
  type :: qux
    private
    type(c_ptr) :: ptr = C_NULL_PTR
  end type qux
end module baz
which matches the xc_f03_lib_m more, that is the only commit which changes the result.

So, my question is, if the module files are really incompatible between GCC 14 and 15, because of r15-4295 or all 3 commits, shouldn't we bump module.cc (MOD_VERSION) macro?
Or change the r15-4295 commit such that it is compatible for the modules?
Comment 1 Thomas Koenig 2025-01-07 18:51:04 UTC
Probably safest to bump the module version....
Comment 2 kargls 2025-01-07 19:02:15 UTC
(In reply to Thomas Koenig from comment #1)
> Probably safest to bump the module version....

Agree with Thomas, here.  The internally generated iso_c_binding module
from 14 and 15 are different.  If a module USEs iso_c_binding and is 
compiled by 14, then the resulting module will likely run into
compatibility issues.
Comment 3 Jakub Jelinek 2025-01-07 19:08:30 UTC
I wonder if the incompatibility isn't just about the iso-c-binding.def (and maybe iso-fortran-env.def) changes inserting stuff in the middle rather than always just appending it to the end.
The 42 to 63 change is 21, and there are 21 NAMED_UINTCST entries added into the middle of iso-c-binding.def (and one NAMED_FUNCTION added at the end).
iso-fortran-env.def has 5 NAMED_INTCST and 4 NAMED_UINTCSTs added into the middle.

I don't know if those could be moved to the end and whether it would then work fine or not.  And whether this is just about the intrindic modules or not.
Though, even if stuff is just added at the end, I wonder if GCC 15 compiled *.mod files that use somewhere the new iso-c-binding etc. entries won't cause crashes when compiled by GCC 14.
So maybe bumping MOD_VERSION is really the only solution.
Note, diffing those *.def files between GCC 11 and 14, there were no additions/removals there.
Comment 4 kargls 2025-01-07 19:28:08 UTC
(In reply to Jakub Jelinek from comment #3)
> I wonder if the incompatibility isn't just about the iso-c-binding.def (and
> maybe iso-fortran-env.def) changes inserting stuff in the middle rather than
> always just appending it to the end.
> The 42 to 63 change is 21, and there are 21 NAMED_UINTCST entries added into
> the middle of iso-c-binding.def (and one NAMED_FUNCTION added at the end).
> iso-fortran-env.def has 5 NAMED_INTCST and 4 NAMED_UINTCSTs added into the
> middle.
> 
> I don't know if those could be moved to the end and whether it would then
> work fine or not.  And whether this is just about the intrindic modules or
> not.
> Though, even if stuff is just added at the end, I wonder if GCC 15 compiled
> *.mod files that use somewhere the new iso-c-binding etc. entries won't
> cause crashes when compiled by GCC 14.
> So maybe bumping MOD_VERSION is really the only solution.
> Note, diffing those *.def files between GCC 11 and 14, there were no
> additions/removals there.

You may be correct, appending changes to iso_c_binding may
allow a module compiled with 14 to work with 15, but there is
an issue in the opposite direction.

That is, if you compile the following with 15,

% cat foo.f90
   module foo
     use iso_c_binding
     private
     public f_c_string, c_char
  end module

you have

% zcat foo.mod
GFORTRAN module version '15' created from m90types.f90
(() () () () () () () () () () () () () () () () () () () () () () () ()
() () ())
...
('__def_init___iso_c_binding_C_funptr' 0 2
'__def_init___iso_c_binding_C_ptr' 0 4 '__vtab___iso_c_binding_C_funptr'
0 6 '__vtab___iso_c_binding_C_ptr' 0 8 '__vtype___iso_c_binding_C_funptr'
0 7 '__vtype___iso_c_binding_C_ptr' 0 9 'c_char' 0 26 'f_c_string' 0 27)

If you now compile the following with 14

  program bar
    use foo
    print *, len(f_c_string(c_char_'abc'))
  end program

you get

% gfortran14 -o z ss.f90 
f951: internal compiler error: in gfc_intrinsic_function_by_id, at fortran/intrinsic.cc:1069
0x247159ab9 __libc_start1
        /usr/src/lib/libc/csu/libc_start1.c:157
Please submit a full bug report, with preprocessed source (by using -freport-bug).
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.

The ICE is similar to what you report.  Even if the module is arranged
to prevent the ICE. 14's libgfortran.so does not contain f_c_string(),
so it will not compile due to a missing reference.
Comment 5 Jakub Jelinek 2025-01-07 20:43:26 UTC
Ok, I'll bootstrap/regtest
2025-01-07  Jakub Jelinek  <jakub@redhat.com>

	PR fortran/118337
	* module.cc (MOD_VERSION): Bump to "16".

--- gcc/fortran/module.cc.jj	2025-01-02 11:47:31.697201637 +0100
+++ gcc/fortran/module.cc	2025-01-07 21:41:46.866494776 +0100
@@ -84,7 +84,7 @@ along with GCC; see the file COPYING3.
 
 /* Don't put any single quote (') in MOD_VERSION, if you want it to be
    recognized.  */
-#define MOD_VERSION "15"
+#define MOD_VERSION "16"
 
 
 /* Structure that describes a position within a module file.  */
momentarily.
Comment 6 anlauf 2025-01-07 20:49:13 UTC
(In reply to kargls from comment #4)
> If you now compile the following with 14
> 
>   program bar
>     use foo
>     print *, len(f_c_string(c_char_'abc'))
>   end program
> 
> you get
> 
> % gfortran14 -o z ss.f90 
> f951: internal compiler error: in gfc_intrinsic_function_by_id, at
> fortran/intrinsic.cc:1069
> 0x247159ab9 __libc_start1
>         /usr/src/lib/libc/csu/libc_start1.c:157
> Please submit a full bug report, with preprocessed source (by using
> -freport-bug).
> Please include the complete backtrace with any bug report.
> See <https://gcc.gnu.org/bugs/> for instructions.
> 
> The ICE is similar to what you report.  Even if the module is arranged
> to prevent the ICE. 14's libgfortran.so does not contain f_c_string(),
> so it will not compile due to a missing reference.

It is clear that one cannot have 2-way compatibility.

But I wish we could have a limited version of backward-compatibility,
i.e. trying to consume older module versions with newer compilers.
Commercial compilers at least try.  We might do that for our users, too.

It is a PITA to have to recompile a full software stack only because
there is a simple addition to the module format.
Comment 7 Thomas Koenig 2025-01-07 21:51:15 UTC
(In reply to anlauf from comment #6)

> It is clear that one cannot have 2-way compatibility.
> 
> But I wish we could have a limited version of backward-compatibility,
> i.e. trying to consume older module versions with newer compilers.
> Commercial compilers at least try.  We might do that for our users, too.
> 
> It is a PITA to have to recompile a full software stack only because
> there is a simple addition to the module format.

This is doable, if a bit of work. We would need to put a version number
on our intrinsic module entities and write this out. On reading,
anything with a higher number than what the current compiler supports
will then be discarded.  If we do that, and take care not to disturb
the previous numbers when adding something new, that could work.
A bit like the symbol versioning in the shared libraries...

We need to bump the module version anyway.  Is this something
we could still fit in (with the required testing) before release?
Comment 8 Richard Biener 2025-01-08 07:57:30 UTC
(In reply to Thomas Koenig from comment #7)
> (In reply to anlauf from comment #6)
> 
> > It is clear that one cannot have 2-way compatibility.
> > 
> > But I wish we could have a limited version of backward-compatibility,
> > i.e. trying to consume older module versions with newer compilers.
> > Commercial compilers at least try.  We might do that for our users, too.
> > 
> > It is a PITA to have to recompile a full software stack only because
> > there is a simple addition to the module format.
> 
> This is doable, if a bit of work. We would need to put a version number
> on our intrinsic module entities and write this out. On reading,
> anything with a higher number than what the current compiler supports
> will then be discarded.  If we do that, and take care not to disturb
> the previous numbers when adding something new, that could work.
> A bit like the symbol versioning in the shared libraries...
> 
> We need to bump the module version anyway.  Is this something
> we could still fit in (with the required testing) before release?

Given Fortran is not a primary language it's your call.  That said, if we
re-order the intrinsic module .def file changes GCC 15, with changed
module version to 16, could be made to accept version 15 module files
as well, right?  And GCC 14 would reject the version 16 modules correctly.

Future-proofing in a less explicit way would of course be nice.
Comment 9 Richard Biener 2025-01-08 07:58:22 UTC
Btw, the fortran module version change should be documented in changes.html
Comment 10 Jakub Jelinek 2025-01-08 13:14:55 UTC
Short reproducer for one of the ICEs:
/usr/src/gcc-15/obj/gcc/f951 -quiet libxc_master.f90                                                                                                                                  
/usr/src/gcc-15/obj/gcc/f951 -quiet fu.f90                                                                                                                                            
This compiles fine                                                                                                                                                                    
/usr/src/gcc-14/obj/gcc/f951 -quiet libxc_master.f90                                                                                                                                  
/usr/src/gcc-15/obj/gcc/f951 -quiet fu.f90                                                                                                                                            
fu.f90:10:18:                                                                                                                                                                         
                                                                                                                                                                                      
   10 | end subroutine foo                                                                                                                                                            
      |                  1                                                                                                                                                            
internal compiler error: tree check: expected record_type or union_type or qual_union_type, have pointer_type in gfc_trans_structure_assign, at fortran/trans-expr.cc:9906            
0x2d322df internal_error(char const*, ...)                                                                                                                                            
        ../../gcc/diagnostic-global-context.cc:517                                                                                                                                    
0x12fd1d3 tree_check_failed(tree_node const*, char const*, int, char const*, ...)                                                                                                     
        ../../gcc/tree.cc:9044                                                                                                                                                        
0x5b6939 tree_check3(tree_node*, char const*, int, char const*, tree_code, tree_code, tree_code)                                                                                      
        ../../gcc/tree.h:3705                                                                                                                                                         
0x602a93 gfc_trans_structure_assign(tree_node*, gfc_expr*, bool, bool)                                                                                                                
        ../../gcc/fortran/trans-expr.cc:9906                                                                                                                                          
0x6033c3 gfc_conv_structure(gfc_se*, gfc_expr*, int)                                                                                                                                  
        ../../gcc/fortran/trans-expr.cc:10063                                                                                                                                         
0x603bb3 gfc_conv_expr(gfc_se*, gfc_expr*)                                                                                                                                            
        ../../gcc/fortran/trans-expr.cc:10231                                                                                                                                         
0x602815 gfc_trans_subcomponent_assign                                                                                                                                                
        ../../gcc/fortran/trans-expr.cc:9864                                                                                                                                          
0x60303e gfc_trans_structure_assign(tree_node*, gfc_expr*, bool, bool)                                                                                                                
        ../../gcc/fortran/trans-expr.cc:9997                                                                                                                                          
0x6033c3 gfc_conv_structure(gfc_se*, gfc_expr*, int)                                                                                                                                  
        ../../gcc/fortran/trans-expr.cc:10063                                                                                                                                         
0x603bb3 gfc_conv_expr(gfc_se*, gfc_expr*)                                                                                                                                            
        ../../gcc/fortran/trans-expr.cc:10231                                                                                                                                         
0x60cad7 gfc_trans_assignment_1                                                                                                                                                       
        ../../gcc/fortran/trans-expr.cc:12806                                                                                                                                         
0x60dfc8 gfc_trans_assignment(gfc_expr*, gfc_expr*, bool, bool, bool, bool)                                                                                                           
        ../../gcc/fortran/trans-expr.cc:13213                                                                                                                                         
0x5ce01c gfc_init_default_dt(gfc_symbol*, stmtblock_t*, bool)                                                                                                                         
        ../../gcc/fortran/trans-decl.cc:4487                                                                                                                                          
0x5d0cdc gfc_trans_deferred_vars(gfc_symbol*, gfc_wrapped_block*)                                                                                                                     
        ../../gcc/fortran/trans-decl.cc:5266                                                                                                                                          
0x5dc20b gfc_generate_function_code(gfc_namespace*)                                                                                                                                   
        ../../gcc/fortran/trans-decl.cc:8148                                                                                                                                          
0x58e092 gfc_generate_module_code(gfc_namespace*)                                                                                                                                     
        ../../gcc/fortran/trans.cc:2764                                                                                                                                               
0x5058b8 translate_all_program_units                                                                                                                                                  
        ../../gcc/fortran/parse.cc:7216                                                                                                                                               
0x5062b7 gfc_parse_file()                                                                                                                                                             
        ../../gcc/fortran/parse.cc:7546                                                                                                                                               
0x573b33 gfc_be_parse_file                                                                                                                                                            
        ../../gcc/fortran/f95-lang.cc:241                                                                                                                                             
Please submit a full bug report, with preprocessed source (by using -freport-bug).                                                                                                    
Please include the complete backtrace with any bug report.                                                                                                                            
See <https://gcc.gnu.org/bugs/> for instructions.
Comment 11 Jakub Jelinek 2025-01-08 13:15:23 UTC
Created attachment 60073 [details]
libxc_master.f90
Comment 12 Jakub Jelinek 2025-01-08 13:15:41 UTC
Created attachment 60074 [details]
fu.f90
Comment 13 GCC Commits 2025-01-08 19:08:57 UTC
The master branch has been updated by Jakub Jelinek <jakub@gcc.gnu.org>:

https://gcc.gnu.org/g:21ee71afa72746367cab7847f950448f04607dd2

commit r15-6704-g21ee71afa72746367cab7847f950448f04607dd2
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Wed Jan 8 20:07:47 2025 +0100

    fortran: Bump MOD_VERSION to "16" [PR118337]
    
    As mentioned in the PR, there is a *.mod incompatibility between GCC 14 and
    GCC 15, at least when using iso_c_binding or iso_fortran_env intrinsic
    modules, because new entries have been added to those modules in the middle,
    causing changes in the constants emitted in the *.mod files.
    
    Also, I fear modules produced with GCC 15 with -funsigned and using UNSIGNED
    in the modules will be unreadable by GCC 14.
    
    The following patch just bumps MOD_VERSION for this.
    
    Note, a patch for accepting also MOD_VERSION "15" has been posted
    incrementally.
    
    2025-01-08  Jakub Jelinek  <jakub@redhat.com>
    
            PR fortran/118337
            * module.cc (MOD_VERSION): Bump to "16".
Comment 14 GCC Commits 2025-01-09 07:29:18 UTC
The master branch has been updated by Jakub Jelinek <jakub@gcc.gnu.org>:

https://gcc.gnu.org/g:c5e71d22d632889860ef079d4b0bff21eef8a660

commit r15-6724-gc5e71d22d632889860ef079d4b0bff21eef8a660
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Thu Jan 9 08:25:49 2025 +0100

    fortran: Accept "15" modules for compatibility [PR118337]
    
    Based on the comments in the PR, I've tried to write a patch which would
    try to keep backwards compatibility with the GCC 11-14 *.mod files.
    This means reordering the *.def files, so that the entries present already
    in GCC 11-14 come before the ones new in GCC 15, and tweaking modules.cc
    such that it can accept that ordering and while it has a newer MOD_VERSION,
    it accepts even the previous one when loading modules.
    
    2025-01-09  Jakub Jelinek  <jakub@redhat.com>
    
            PR fortran/118337
            * module.cc (COMPAT_MOD_VERSIONS): Define.
            (use_iso_fortran_env_module): Don't assume all NAMED_INTCSTs come
            first followed by NAMED_UINTCSTs.
            (gfc_use_module): Accept also COMPAT_MOD_VERSIONS for compatibility.
            * iso-c-binding.def: Reorder entries so that the GCC 14 ones come
            before the ones new in GCC 15.
            * iso-fortran-env.def: Likewise.
Comment 15 Jakub Jelinek 2025-01-09 07:33:03 UTC
Fixed.
Comment 16 GCC Commits 2025-01-09 11:22:31 UTC
The master branch has been updated by Andre Vehreschild <vehre@gcc.gnu.org>:

https://gcc.gnu.org/g:d107140205537aec9c8e235d869b166e9b884775

commit r15-6729-gd107140205537aec9c8e235d869b166e9b884775
Author: Andre Vehreschild <vehre@gcc.gnu.org>
Date:   Wed Jan 8 14:58:35 2025 +0100

    Fortran: Cylce detection for non vtypes only. [PR118337]
    
    gcc/fortran/ChangeLog:
    
            PR fortran/118337
    
            * resolve.cc (resolve_fl_derived0): Exempt vtypes from cycle
            detection.
Comment 17 GCC Commits 2025-01-10 09:30:25 UTC
The master branch has been updated by Jakub Jelinek <jakub@gcc.gnu.org>:

https://gcc.gnu.org/g:f5e488c0ee663c2355e6d712ffc15da215d9cd96

commit r15-6758-gf5e488c0ee663c2355e6d712ffc15da215d9cd96
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Fri Jan 10 10:28:18 2025 +0100

    fortran: use_iso_fortran_env_module tweaks [PR118337]
    
    This patch adds a comment to explain why we initialize the non-constant
    elts of symbol array separately and checking assert to verify that separate
    initialization bumps the iterator for each macro.
    
    2025-01-10  Jakub Jelinek  <jakub@redhat.com>
    
            PR fortran/118337
            * module.cc (use_iso_fortran_env_module): Add a comment explaining
            the optimization performed.  Add gcc_checking_assert that i was
            incremented for all the elements.  Formatting fix.