This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/51514] New: [OOP] Wrong code when passing a CLASS to a TYPE
- From: "burnus at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 12 Dec 2011 14:50:50 +0000
- Subject: [Bug fortran/51514] New: [OOP] Wrong code when passing a CLASS to a TYPE
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51514
Bug #: 51514
Summary: [OOP] Wrong code when passing a CLASS to a TYPE
Classification: Unclassified
Product: gcc
Version: 4.7.0
Status: UNCONFIRMED
Keywords: wrong-code
Severity: normal
Priority: P3
Component: fortran
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: burnus@gcc.gnu.org
The following program (subprog_poly_nonpoly_01_pos.f90) of Reinhold Bader's
test suite fails with at run time with:
==17368== Invalid read of size 4
==17368== at 0x400AB4: MAIN__ (subprog_poly_nonpoly_01_pos.f90:21)
==17368== by 0x400BCD: main (subprog_poly_nonpoly_01_pos.f90:16)
That's the line:
if (xx%i == 3) then
The problem is that one passes the CLASS and not the TYPE to the subroutine:
subpr (&xx);
if (xx._data->i == 3)
The first line should have been subpr(&xx._data)
It works with the Intel Compiler 12.1. (See also PR 46990.)
module mod_subpr
implicit none
type :: foo
integer :: i = 2
end type
type, extends(foo) :: foo_1
real :: r(2)
end type
contains
subroutine subpr(x)
type(foo) :: x
x%i = 3
end subroutine
end module
program prog
use mod_subpr
implicit none
class(foo), allocatable :: xx
allocate(foo_1 :: xx)
call subpr(xx)
if (xx%i == 3) then
write(*,*) 'OK'
else
write(*,*) 'FAIL'
end if
end program