https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118705

Paul Thomas <pault at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
            Summary|Issue compiling derived     |[17 regression] Issue
                   |types when split into       |compiling derived types
                   |submodules                  |when split into submodules
                 CC|                            |pault at gcc dot gnu.org
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2026-06-07

--- Comment #4 from Paul Thomas <pault at gcc dot gnu.org> ---
This is fixed in gcc-16. Regression caused by patch for pr125527.

This PR is cured by:

index a4c3c37104a..3f10ba26c3c 100644
--- a/gcc/fortran/class.cc
+++ b/gcc/fortran/class.cc
@@ -2491,6 +2491,7 @@ gfc_find_derived_vtab (gfc_symbol *derived)
   /* Work in the gsymbol namespace if the top-level namespace is a module.
      This ensures that the vtable is unique, which is required since we use
      its address in SELECT TYPE.  */
+  gfc_namespace *module_ns = ns;
   if (gsym && gsym->ns && ns && ns->proc_name
       && ns->proc_name->attr.flavor == FL_MODULE)
     ns = gsym->ns;
@@ -2516,6 +2517,11 @@ gfc_find_derived_vtab (gfc_symbol *derived)
        gfc_find_symbol (name, ns, 0, &vtab);
       if (vtab == NULL)
        gfc_find_symbol (name, derived->ns, 0, &vtab);
+      /* Also look in the original top-level module/submodule namespace so
that
+        the module variable translation and the procedure body translation
+        find the same frontend symbol and thus the same backend decl.  */
+      if (vtab == NULL && module_ns != ns)
+       gfc_find_symbol (name, module_ns, 0, &vtab);

       if (vtab == NULL)
        {

Reply via email to