https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59104

Francois-Xavier Coudert <fxcoudert at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|2013-12-19 00:00:00         |2015-8-18
                 CC|                            |fxcoudert at gcc dot gnu.org
             Blocks|                            |32834

--- Comment #2 from Francois-Xavier Coudert <fxcoudert at gcc dot gnu.org> ---
F95 bug. Still present. In the generated code, the size of Y is computed before
the bounds for the F result are set, which leads to the error.


Slightly reduced testcase:

$ cat a.f90                         
program bug3
 real y(2)
 y = f(2)
 print *, y
contains
  function f(x)
    integer x
    real f(x)
    integer y(size(f))

    write(*,*) 'size(f) = ',size(f)
    write(*,*) 'size(y) = ',size(y)
    f = -42
  end function f
end program bug3

$ gfortran a.f90 -std=f95 && ./a.out
 size(f) =            2
 size(y) =            0
  -42.0000000      -42.0000000    


Slight modification of the source leads to an ICE on what I think is invalid
code:

$ cat a.f90
  function f(x)
    integer x
    integer y(size(f))
    real f(x)

    write(*,*) 'size(f) = ',size(f)
    write(*,*) 'size(y) = ',size(y)
    f = -42
  end function f

$ gfortran a.f90 -std=f95 && ./a.out
a.f90:3:0:

     integer y(size(f))
 1
internal compiler error: in gfc_conv_expr_descriptor, at
fortran/trans-array.c:6534


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=32834
[Bug 32834] [Meta-bug] 'Fortran 95'-only failures

Reply via email to