http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50640
--- Comment #20 from Tobias Burnus <burnus at gcc dot gnu.org> 2011-11-07 16:17:34 UTC --- (In reply to comment #18) > (In reply to comment #16) > > Created attachment 25730 [details] > > Possible patch which pushes the vtab to the toplevel The reason for the failure is clear: For the derived type/class, the function __copy_xtt_Foo is created. The created function is in the scope of the derived type - which is declared in program xtt. If one now places the "vtab" at the top level, the copy function is hidden in another function as nested function. Hence, one also needs to create the function at top level; I wonder whether this can be already done at decl time in gfc_find_derived_vtab.