This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Fix PR middle-end/20030, fold_indirect_ref and non zero lower bounds


What is happening here is that the fortran front-end creates an array which has a
lower bound of 1 and then casts the reference to one of those to the pointer type
of the type (of what is in the array) and the dereferences it. fold_indirect_ref
would get the lower bound wrong which causes us to create wrong code.


This patch fixes the bug via using the correct index for the array (the lower bound
of the array).


OK? Tested on powerpc-darwin with no regressions.

Thanks,
Andrew Pinski

ChangeLog:

* fold-const.c (fold_indirect_ref_1): Use the correct index for zero access,
the lower bound of the array type.


Attachment: temp.diff.txt
Description: Text document



Testcase:
      program foo
      character*1 a1, a2, b
      a1='A'
      a2='A'
      b='B'
      x = LSAME(a1,a2)
      if ( x.eq.1 ) then
        write(*,*) 'passsed'
      else
        write(*,*) 'failed'
      endif
      end

      logical function LSAME( CA, CB )
      character CA, CB
      integer   INTA, INTB

      INTA = ICHAR( CA )
      INTB = ICHAR( CB )
      LSAME = INTA.EQ.INTB
      end

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]