http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54618
Bug #: 54618 Summary: [OOP] wrong-code with CLASS(...), INTENT(OUT) -- and OPTIONAL or ALLOCATABLE Classification: Unclassified Product: gcc Version: 4.8.0 Status: UNCONFIRMED Keywords: wrong-code Severity: normal Priority: P3 Component: fortran AssignedTo: unassig...@gcc.gnu.org ReportedBy: bur...@gcc.gnu.org CC: ja...@gcc.gnu.org The following program gives an ICE because one has: f (struct __class_p_T * y) { __builtin_memcpy (y->_data, y->_vptr->_def_init, y->_vptr->_size); } The code lacks an "if (y->_data)" check via gfc_conv_expr_present in init_intent_out_dt. program p type t end type t type(t) :: x call f(x) call f() contains subroutine f(y) class(t), intent(out), optional :: y end subroutine f end program p * * * While the following program fails because there is no deallocate/memcpy in f: f (struct __class_p_T_a & restrict y) { } program p type t end type t type, extends(t):: t2 end type t2 class(t), allocatable :: x,y allocate (t2 :: x) call f(x) if (allocated (x) .or. .not. same_type_as (x,y)) call abort() contains subroutine f(y) class(t), intent(out), allocatable :: y end subroutine f end program p