Hi all,

the SIZEOF intrinsic currently returns the size according to the
*declared* type for polymorphic variables. I think this doesn't really
make much sense and it also causes ICEs when SIZEOF is called on
CLASS(*) variables (which don't really have a declared type).
Therefore I'm proposing to make SIZEOF return the size according to
the *dynamic* type instead. The same is done by STORAGE_SIZE (F08),
which however gives the size in bits. SIZEOF is a GNU extension, so we
are free to decide on its behavior. I don't remember why the declared
type was chosen in the first place, and I hope that no one seriously
depends on the current behavior (the size of the declared type is
probably not really useful after all).

The patch was regtested on x86_64-unknown-linux-gnu. Ok for trunk?

Cheers,
Janus


2013-08-22  Janus Weil  <ja...@gcc.gnu.org>

    PR fortran/57305
    * intrinsic.texi (SIZEOF): Update documentation.
    * trans-intrinsic.c (gfc_conv_intrinsic_sizeof): Make SIZEOF return the
    size of the dynamic type for polymorphic variables.


2013-08-22  Janus Weil  <ja...@gcc.gnu.org>

    PR fortran/57305
    * gfortran.dg/storage_size_1.f08: Modified.
    * gfortran.dg/sizeof_4.f90: New.

Attachment: pr57305.diff
Description: Binary data

Attachment: sizeof_4.f90
Description: Binary data

Reply via email to