https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84511
Bug ID: 84511 Summary: Internal compiler error from directly printing return of C_LOC Product: gcc Version: 7.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: h.ratcliffe at warwick dot ac.uk Target Milestone: --- Created attachment 43487 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=43487&action=edit Tarball of 2-file working example Directly printing return from C_LOC causes an internal compiler error if C_LOC is called on a type defined in a module in a separate file. Capturing the return and then printing succeeds. Full error report is f951: internal compiler error: Bad IO basetype (10) 0x5cbd3f gfc_internal_error(char const*, ...) ../../src/gcc/fortran/error.c:1348 0x6bd3fe transfer_expr ../../src/gcc/fortran/trans-io.c:2475 0x6c0748 gfc_trans_transfer(gfc_code*) ../../src/gcc/fortran/trans-io.c:2620 0x6697a7 trans_code ../../src/gcc/fortran/trans.c:2017 0x6be1d6 build_dt ../../src/gcc/fortran/trans-io.c:2028 0x669787 trans_code ../../src/gcc/fortran/trans.c:1989 0x68e887 gfc_generate_function_code(gfc_namespace*) ../../src/gcc/fortran/trans-decl.c:6332 0x66d1f9 gfc_generate_module_code(gfc_namespace*) ../../src/gcc/fortran/trans.c:2195 0x622f3b translate_all_program_units ../../src/gcc/fortran/parse.c:6061 0x622f3b gfc_parse_file() ../../src/gcc/fortran/parse.c:6274 0x66600f gfc_be_parse_file ../../src/gcc/fortran/f95-lang.c:204 Same error arises on gfortran 5.4 and 7.2.0 on Ubuntu and 6.3.0 on OSX, but 4.3.4 on SLES 11 (SP4) succeeds. The error does not occur if module TWO defining the type is in the file where C_LOC is called.