$> cat ice.f90 MODULE kd_kd_tree_type TYPE :: kd_tree_node TYPE(kd_tree_node_private), POINTER :: p END TYPE TYPE :: kd_tree_node_private INTEGER :: dummy END TYPE TYPE :: kd_tree TYPE(kd_tree_node) :: root END TYPE CONTAINS SUBROUTINE kd_tree_init_default(this) TYPE(kd_tree), INTENT(inout) :: this ! this = kd_tree(kd_tree_node(null())) ! correct this = kd_tree(null()) ! ICE END SUBROUTINE END MODULE $> gfortran-svn ice.f90 ice.f90: In function 'kd_tree_init_default': ice.f90:15: internal compiler error: in fold_convert, at fold-const.c:2629 Please submit a full bug report, $> gfortran-svn -v gcc version 4.3.0 20080107 (experimental) Backtrace: (gdb) bt #0 fancy_abort (file=0x87f3ec4 "../../../svn/gcc/gcc/fold-const.c", line=2629, function=0x87f8472 "fold_convert") at ../../../svn/gcc/gcc/diagnostic.c:659 #1 0x0824efd1 in fold_convert (type=0xb7d0f548, arg=0xb7cd39d8) at ../../../svn/gcc/gcc/fold-const.c:2629 #2 0x080f378b in gfc_trans_subcomponent_assign (dest=0xb7cde078, cm=0x89ba8d0, expr=0x89bb1c8) at ../../../svn/gcc/gcc/fortran/trans-expr.c:3354 #3 0x080f396a in gfc_trans_structure_assign (dest=0xb7cdd108, expr=<value optimized out>) at ../../../svn/gcc/gcc/fortran/trans-expr.c:3414 #4 0x080f3b8b in gfc_conv_structure (se=0xbfec283c, expr=0x89bb760, init=0) at ../../../svn/gcc/gcc/fortran/trans-expr.c:3441 #5 0x080ef85c in gfc_conv_expr (se=0xbfec283c, expr=0x89bb760) at ../../../svn/gcc/gcc/fortran/trans-expr.c:3563 #6 0x080f0ab0 in gfc_trans_assignment_1 (expr1=0x89bb100, expr2=0x89bb760, init_flag=0 '\0') at ../../../svn/gcc/gcc/fortran/trans-expr.c:4293 #7 0x080f0c4c in gfc_trans_assignment (expr1=0x89bb100, expr2=0x89bb760, init_flag=72 'H') at ../../../svn/gcc/gcc/fortran/trans-expr.c:4440 #8 0x080f17e1 in gfc_trans_assign (code=0x89bb7d0) at ../../../svn/gcc/gcc/fortran/trans-expr.c:4452 #9 0x080cfe90 in gfc_trans_code (code=0x89bb7d0) at ../../../svn/gcc/gcc/fortran/trans.c:994 #10 0x080e7cc2 in gfc_generate_function_code (ns=0x89ba920) at ../../../svn/gcc/gcc/fortran/trans-decl.c:3298 #11 0x080cd01a in gfc_generate_module_code (ns=0x89b9e20) at ../../../svn/gcc/gcc/fortran/trans.c:1214 #12 0x0809f219 in gfc_parse_file () at ../../../svn/gcc/gcc/fortran/parse.c:3391 #13 0x080c8985 in gfc_be_parse_file (set_yydebug=0) at ../../../svn/gcc/gcc/fortran/f95-lang.c:260 #14 0x0836c6d4 in toplev_main (argc=2, argv=0xbfec2ca4) at ../../../svn/gcc/gcc/toplev.c:1042 #15 0x08114b1f in main (argc=16, argv=0x0) at ../../../svn/gcc/gcc/main.c:35 This might be related to (or be a dupe of) PR33295.
Simplified testcase: SUBROUTINE kd_tree_init_default() TYPE :: kd_tree_node INTEGER :: dummy END TYPE TYPE :: kd_tree TYPE(kd_tree_node) :: root END TYPE TYPE(kd_tree) :: tree tree = kd_tree(null()) END SUBROUTINE
I'll take this on as relief from memory leaks.... Paul
Last night, I tracked this to resolve.c (resolve_structure_cons), but I was not 100% sure what to do. With the simplified testcase, Intel complains: $> ifort pr34813.f90 fortcom: Error: pr34813.f90, line 15: The type of the NULL(MOLD) element in a structure-constructor differs from the type of the component in the derived-type-def. tree = kd_tree(kd_tree_node(null())) -----------------------------^ fortcom: Error: pr34813.f90, line 15: This array or function or substring is invalid in constant expressions. tree = kd_tree(kd_tree_node(null())) ----------------^ fortcom: Error: pr34813.f90, line 15: Replacing invalid structure constructor by integer 1 [<NULL_STRING>] tree = kd_tree(kd_tree_node(null())) ^ Interestingly, if it is slightly changed, - tree = kd_tree(kd_tree_node(null())) + integer, pointer :: i + tree = kd_tree(kd_tree_node(null(i))) Intel gives an ICE while gfortran happily (but wrongly?) accepts it: $> ifort -warn all pr34813.f90 fortcom: Severe: pr34813.f90, line 12: **Internal compiler error: internal abort** Please report this error along with the circumstances in which it occurred in a Software Problem Report. Note: File and line given may not be explicit cause of this error. tree = kd_tree(kd_tree_node(null(i))) ------------------------------^
Subject: Bug 34813 Author: pault Date: Mon Mar 24 19:11:24 2008 New Revision: 133488 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=133488 Log: 2008-03-24 Paul Thomas <pault@gcc.gnu.org> PR fortran/34813 * resolve.c (resolve_structure_cons): It is an error to assign NULL to anything other than a pointer or allocatable component. PR fortran/33295 * resolve.c (resolve_symbol): If the symbol is a derived type, resolve the derived type. If the symbol is a derived type function, ensure that the derived type is visible in the same namespace as the function. 2008-03-24 Paul Thomas <pault@gcc.gnu.org> PR fortran/34813 * gfortran.dg/null_3.f90 : New test PR fortran/33295 * gfortran.dg/module_function_type_1.f90 : New test Added: trunk/gcc/testsuite/gfortran.dg/module_function_type_1.f90 trunk/gcc/testsuite/gfortran.dg/null_3.f90 Modified: trunk/gcc/fortran/ChangeLog trunk/gcc/fortran/resolve.c trunk/gcc/testsuite/ChangeLog
Subject: Bug 34813 Author: pault Date: Mon Mar 24 21:10:36 2008 New Revision: 133490 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=133490 Log: 2008-03-24 Paul Thomas <pault@gcc.gnu.org> PR fortran/34813 * resolve.c (resolve_structure_cons): It is an error to assign NULL to anything other than a pointer or allocatable component. PR fortran/33295 * resolve.c (resolve_symbol): If the symbol is a derived type, resolve the derived type. If the symbol is a derived type function, ensure that the derived type is visible in the same namespace as the function. 2008-03-24 Paul Thomas <pault@gcc.gnu.org> PR fortran/34813 * gfortran.dg/null_3.f90 : New test PR fortran/33295 * gfortran.dg/module_function_type_1.f90 : New test Added: branches/gcc-4_3-branch/gcc/testsuite/gfortran.dg/module_function_type_1.f90 branches/gcc-4_3-branch/gcc/testsuite/gfortran.dg/null_3.f90 Modified: branches/gcc-4_3-branch/gcc/fortran/ChangeLog branches/gcc-4_3-branch/gcc/fortran/resolve.c branches/gcc-4_3-branch/gcc/testsuite/ChangeLog
Fixed on trumk and 4.3. Thanks for the report. Paul