[Bug fortran/50981] [4.4/4.5/4.6 Regression] Wrong-code for scalarizing ELEMENTAL call with absent OPTIONAL argument

dominiq at lps dot ens.fr gcc-bugzilla@gcc.gnu.org
Sat Jan 28 14:00:00 GMT 2012


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

--- Comment #31 from Dominique d'Humieres <dominiq at lps dot ens.fr> 2012-01-28 11:40:17 UTC ---
> The test in comment #23 gives an ICE with/without the patch:
>
> pr50981_4.f90: In function 'MAIN__':
> pr50981_4.f90:16:0: internal compiler error: in fold_convert_loc, at
> fold-const.c:2016
>
> i.e., the same ICE as for pr51977 (I did not tested the patchlet in comment
> #27).

This was pr52016 fixed by revision 183625. Looking further to this test, I have
found the following reduced test which gives a segmentation fault at run time:

    type t
      integer :: a
    end type t
  type(t), allocatable :: var1, var2(:)
  call sub_cta(var2)

contains
  subroutine sub_cta(y)
    class(t), intent(inout), optional :: y(:)
! FIXME: PR 46356 ?
    print *, present(y)
    if (present(y)) y%a = 7
    if (present(y)) i = 7
  end subroutine sub_cta
end

[macbook] f90/bug% gfc pr50981_4_red_1.f90 
[macbook] f90/bug% a.out
 T

Program received signal SIGSEGV: Segmentation fault - invalid memory reference.
...

i.e., the unallocated 'var2' is viewed as present.



More information about the Gcc-bugs mailing list