Fortran fixes regression caused by first patch
A Fortran compiler regression, linked to a previous patch, caused issues with finding virtual function tables, which is now resolved.
A previous Fortran change led to a regression where the compiler failed to correctly locate virtual function tables (vtab). This issue arose because the search for the vtab was not considering the module namespace as a final fallback before constructing a new vtab. The compiler now explicitly stashes and utilizes the module namespace as the last search location, effectively resolving the problem.
In Details
The class.cc file in the Fortran frontend deals with type-bound procedures and virtual method tables (VMTs). Specifically, gfc_find_derived_vtab is responsible for locating or constructing the VMT for derived types. The regression occurred because the search logic within this function did not properly account for the module namespace when resolving vtab symbols, leading to a failure to find an existing table before creating a new one. The fix involves explicitly stashing the module namespace and integrating it into the vtab lookup path as a final attempt to find a previously defined v…
For Context
In object-oriented programming, 'virtual function tables' (often shortened to vtab or VMT) are essential for allowing a program to call the correct version of a function when dealing with inherited objects. The Fortran compiler has a system to find or create these tables. A recent update to the Fortran compiler inadvertently introduced a bug that prevented it from correctly finding these virtual function tables in certain situations, specifically when they were defined within a 'module' (a way to organize code in Fortran). This meant the compiler might fail to link or incorrectly call functions. The fix ensures the compiler always checks the module's definitions as a last resort when looking for these tables, resolving the problem.