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

kargl at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P4
             Status|WAITING                     |NEW
                 CC|                            |kargl at gcc dot gnu.org

--- Comment #2 from kargl at gcc dot gnu.org ---
(In reply to Dominique d'Humieres from comment #1)
> Use
> 
>       integer(4) :: iUnit, iPos
> 
> -fdefault-integer-8 converts iUnit and iPos to integer(8) while open and
> inquire expect default integer, i.e., 4.
> 
> IMO this PR should be closed as INVALID.

There isn't a problem with OPEN.  The dump 
(removing clutter) looks like

testinquire ()
{
  integer(kind=8) ipos;
  integer(kind=8) iunit;

  {
    struct __st_parameter_open open_parm.0;
    integer(kind=4) newunit.1;

    open_parm.0.newunit = &newunit.1;
    _gfortran_st_open (&open_parm.0);
    iunit = (integer(kind=8)) newunit.1;
  }

Here open uses a INTEGER(4) internally and assigns
to the promoted INTEGER(8).

The INQUIRE is however broken for POS, which looks like

  {
    struct __st_parameter_inquire inquire_parm.3;
    integer(kind=8) D.3764;
    inquire_parm.3.strm_pos_out = &ipos;
    inquire_parm.3.common.unit = (integer(kind=4)) iunit;
    _gfortran_st_inquire (&inquire_parm.3);
  }
 }

inquire_parm.3.strm_pos_out is likely an INTEGER(4) and 
gfortran is passing a pointer to an INTEGER(8) ipos.

At one point in time, there was a warning that
-fdefault-integer-8 changes the ABI and possibly
causes problems with libgfortran.  I cannot find
the warning now.  Documentation states

'-fdefault-integer-8'
     Set the default integer and logical types to an
     8 byte wide type.

which means gfortran should compile and execute 
this code.  In fact, gfortran appears broken.

From F03, 9.9.1, R930 has

inquire-spec is [ UNIT = ] file-unit-number
             or POS = scalar-int-variable

Note that does not state scalar-default-int-variable.

Changing the original code to use INTEGER(8) instead of
using the -fdefault-integer-8 shows the same program.

Reply via email to