The following program fails with Error: The derived type 'func' at (1) is of type 't', which has not been defined
module m type t integer :: i = 0 end type t end module m module mm contains type(t) function func() use m end function func end module mm And the now following program (correctly) fails with strange error messages: Error: The derived type 'func2' at (1) is of type '�', which has not been defined module bar end module bar type(non_exist) function func2() use bar end function func2 See also: PR fortran/31154 PR fortran/31229 PR fortran/33334 and PR 34254 I thought the first bug is fixed by the following diff, but it causes a regression in gfortran.dg/alloc_comp_basics_1.f90 Index: gcc/fortran/decl.c =================================================================== --- gcc/fortran/decl.c (revision 130769) +++ gcc/fortran/decl.c (working copy) @@ -2271,7 +2288,8 @@ gfc_match_type_spec (gfc_typespec *ts, i return m; if (gfc_current_state () == COMP_INTERFACE - || gfc_current_state () == COMP_NONE) + || gfc_current_state () == COMP_NONE + || gfc_current_state () == COMP_CONTAINS) { gfc_function_type_locus = loc; ts->type = BT_UNKNOWN; -- Summary: type(t) function with imported/use-associated "t" fails Product: gcc Version: 4.3.0 Status: UNCONFIRMED Keywords: rejects-valid Severity: normal Priority: P3 Component: fortran AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: burnus at gcc dot gnu dot org OtherBugsDependingO 32834 nThis: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34431