------- Additional Comments From tobi at gcc dot gnu dot org  2005-01-21 22:21 
-------
Ugh. This is ugly.

When building the I/O statement, we create a temporary because the argument is
passed by reference (why?).  The type of the temporary is determined as
TREE_TYPE(se->expr), where se->expr is the logical constant.

The type for a logical constant is built like so:
  new_type = make_unsigned_type (bit_size);
  TREE_SET_CODE (new_type, BOOLEAN_TYPE);
  TYPE_MAX_VALUE (new_type) = build_int_cst (new_type, 1);
  TYPE_PRECISION (new_type) = 1;

So, why is a temporary of 32 bits width generated instead of one bit width?

This wrong behavior can be seen in the dumps (with my patch which instruments
the dumper to print the widths of the integer constants). for this source:
   LOGICAL*8 v
   LOGICAL(4), parameter :: l4 = .FALSE.
   LOGICAL(8), parameter :: l8 = .false.

   v = l8
   print *, v
   print *, l4, l8
.t03.original looks like this, after cutting out the I/O related stuff:
  v = 0_U1;  <----------- right
   <snip>
  {
    int4 C.454 = 0_S32; <----------- right

    _gfortran_transfer_logical (&C.454, 4_S32);
  }
  {
    int4 C.455 = 0_S32; <------------ wrong

    _gfortran_transfer_logical (&C.455, 8_S32);
  }


-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |tobi at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19543

Reply via email to