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

Tobias Burnus <burnus at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |burnus at gcc dot gnu.org

--- Comment #10 from Tobias Burnus <burnus at gcc dot gnu.org> ---
In my understanding, the problem is the following (of r254427):
        Unconditionally generate a vtable for any module derived
        type, as long as the standard is F2003 or later and it
        is not a vtype or a PDT template.

The idea is: Any TYPE can be (later) uses in a polymorphic context, hence, one
might need both the v(irtual )table and the default constructor and copy
procedure.

C++ has the same problem, but solves it differently. C++ by default doesn't
create the vtable objects. (Which makes especially sense given that the
class/struct is usually defined in a header.)

But when used, it creates them in every .o which uses them. To avoid linker
problems, those are created as "V"/"W", i.e. as weak objects.

Thus, the gfortran solution could be likewise: Don't emit the vtab, def_init
and copy code when compiling a module (unless used in the module) - and defer
the creation to the later usage.


The question is when does one need to create them? One possibility would be to
create them in each translation unit which passes a TYPE to a
CLASS(*)/CLASS(<type-spec>) and when allocating it or associating it with a
(nonpolymorphic) pointer target. I think that would work.

Reply via email to