There's a difference between the assembly emitted for the following two Fortran
tests:
   PRINT *, .TRUE., .TRUE_8 ; END
and
   PRINT *, .TRUE._8, .TRUE ; END

Where for the former we get
        .align 4
.LC1:
        .long   1
the latter gives:
        .align 8
.LC1:
        .long   1
        .long   0
        .text
and in both cases the constants are referenced by pointing to .LC1, i.e. the
code for the PRINT-statements looks like:
        pushl   $8     ;; or $4 for the 4-byte true
        pushl   $.LC1
        call    _gfortran_transfer_logical

In other words, the code is correct for the former program, but not for the
latter, as here both alignment may be wrong and memory beyond the correctly
initialized space will be read.

Andrew Pinski confirmed that the same difference also exists on powerpc, I
assume that this will make 4-byte .TRUE. to always be evaluated to .FALSE. on
that platform.  On ix86 on the other hand an .FALSE._8 will be evaluating to
true if subsequent memory is non-zero.

NB I mark this as blocking PR19543, I don't know if this is the only issue
remaining with that PR.  Also, I made the component rtl-optimization, as the
tree dumps look correct.

-- 
           Summary: Ordering of clogical onstants determines if they're
                    correctly emitted
           Product: gcc
           Version: 4.0.0
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P2
         Component: rtl-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: tobi at gcc dot gnu dot org
                CC: gcc-bugs at gcc dot gnu dot org
OtherBugsDependingO 19543
             nThis:


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

Reply via email to