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

             Bug #: 51958
           Summary: [4.7 Regression] -ffrontend-optimize generates wrong
                    code
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassig...@gcc.gnu.org
        ReportedBy: bur...@gcc.gnu.org
                CC: tkoe...@gcc.gnu.org


Reported at http://gcc.gnu.org/ml/fortran/2012-01/msg00201.html by Don Simons.

The following program works without front-end optimization but with, the
program does not enter "else if" body. (The program has been modified to call
abort() if this does not happen.)

>From -fdump-tree-original -ffrontend-optimize:

  if (charq[1]{lb: 1 sz: 1} == 32)
    {
          integer(kind=4) __var_1;
...
    }
  else
    {
      if (__var_1 > 96 && __var_1 <= 103)


Thus, the issue is obvious. 

(While I think there is a general issue, I think one should also consider to
not do this optimization for (i)(a)char. I could imagine that the ME has a
simpler task to only track charq[1] instead of also tracking __var_1 and the
assignment to it.)


! ----------------------------------------------
      logical :: passed
      character*1 charq
      charq = 'c'
      passed = .false.
      print*,'ichar is ',ichar(charq)
      if (charq .eq. ' ') then
        print*,'charq is blank'
      else if ((ichar(charq).ge.97 .and. ichar(charq).le.103)) then
        print*,'passed the main test'
        passed = .true.
      end if
      if (.not. passed) then
        print *, 'BUG'
        call abort()
      end if
      print*,'Done'
      end

Reply via email to