[Bug fortran/19543] formated output for logical(8) variables fails

tobi at gcc dot gnu dot org gcc-bugzilla@gcc.gnu.org
Fri Jan 21 22:58:00 GMT 2005


------- Additional Comments From tobi at gcc dot gnu dot org  2005-01-21 22:58 -------
Unfortunately, this patch is not sufficient to fix this issue, as the logical
constants are not dealt with correctly by the middle-end.

The following testcase shouldn't abort:
program test
  implicit none
  logical(1), parameter :: t1 = .TRUE., f1 = .FALSE.
  logical(2), parameter :: t2 = .TRUE., f2 = .FALSE.
  logical(4), parameter :: t4 = .TRUE., f4 = .FALSE.
  logical(8), parameter :: t8 = .TRUE., f8 = .FALSE.
  character*2 :: t(4), f(4)

  write(t(1),*) t1
  write(f(1),*) f1
  write(t(2),*) t2
  write(f(2),*) f2
  write(t(3),*) t4
  write(f(3),*) f4
  write(t(4),*) t8
  write(f(4),*) f8

  if (any(t .ne. " T")) call abort
  if (any(f .ne. " F")) call abort
end

It does, with or without my patch.  Without my patch it only fails for f(4),
i.e. for LOGICAL*8, with my patch it fails for f(2) through to f(4), i.e. for
all logical types which are not byte-sized.

While the .original-dump looks correct with my patch, and not correct without
it, the logical constants get merged in an unhealthy way:
        .align 4
.LC1:
        .long   1
        .align 4
.LC2:
        .long   0
(without my patch, with my patch the alignments disappear, which of course
explains why this fails for anything wider than 32 bits, or byte respectively)

To the potential middle-end hacker looking into this: Fortran's LOGICAL is a
boolean type which is defined as:
  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;
(from trans-types.c, around line 420)
bit_size is one of 8, 16, 32, or 64.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|tobi at gcc dot gnu dot org |unassigned at gcc dot gnu
                   |                            |dot org
             Status|ASSIGNED                    |NEW
           Keywords|patch                       |


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



More information about the Gcc-bugs mailing list