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

             Bug #: 51535
           Summary: Optimization problem with -finit-real=snan at -O1
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassig...@gcc.gnu.org
        ReportedBy: anl...@gmx.de


Hi,

with gfortran 4.7.0 svn rev. 181390 on i686-pc-linux-gnu
I have the following problem:

module mo_usstd
  implicit none
contains
  function p_h_usstd (h) result (p)
    real, intent(in) :: h
    real             :: p
    real             :: sigma, delta
    print *, "In p_h_usstd!"
    call atmosphere (h, sigma, delta)
    p = sigma/delta
  end function p_h_usstd
  subroutine atmosphere (h, sigma, delta)
    real,intent(in) :: h
    real,intent(out):: sigma
    real,intent(out):: delta
    delta = h
    sigma = h
  end subroutine atmosphere
end module mo_usstd

program gfcbug116
  use mo_usstd
  implicit none
  real :: p, h
  h = 5500
  p = p_h_usstd (h)
  print *, p
end program gfcbug116


Compilation:

% /opt/gcc/4.7/bin/gfortran -O1 -march=native -g -fbacktrace
-ffpe-trap=zero,overflow,invalid -finit-real=snan -static-libgfortran
gfcbug116.f90

Running the program, I get an SIGFPE with a backtrace:

Backtrace for this error:
#0  0x8058B3F in _gfortrani_show_backtrace at backtrace.c:261
#1  0x80495AF in _gfortrani_backtrace_handler at compile_options.c:93
#2  0xFFFFE3FF
#3  0x80493C4 in __mo_usstd_MOD_p_h_usstd at gfcbug116.f90:7
#4  0x8049479 in gfcbug116 at gfcbug116.f90:27

Does not make any sense to me.

No problem with -O0, -O2, -O3, -Ofast,-Os
No problem with -finit-real=nan
No problem with 4.6.0

Any ideas what might be going wrong?

Reply via email to