public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/51514] New: [OOP] Wrong code when passing a CLASS to a TYPE
@ 2011-12-12 14:57 burnus at gcc dot gnu.org
  2012-02-03 14:25 ` [Bug fortran/51514] " burnus at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: burnus at gcc dot gnu.org @ 2011-12-12 14:57 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2012-02-07  8:16 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-12-12 14:57 [Bug fortran/51514] New: [OOP] Wrong code when passing a CLASS to a TYPE burnus at gcc dot gnu.org
2012-02-03 14:25 ` [Bug fortran/51514] " burnus at gcc dot gnu.org
2012-02-03 14:29 ` dominiq at lps dot ens.fr
2012-02-03 15:09 ` burnus at gcc dot gnu.org
2012-02-06 11:05 ` [Bug fortran/51514] [OOP] Wrong code when passing a scalar " burnus at gcc dot gnu.org
2012-02-06 14:04 ` burnus at gcc dot gnu.org
2012-02-07  8:15 ` burnus at gcc dot gnu.org
2012-02-07  8:16 ` burnus at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).