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

* [Bug fortran/51514] [OOP] Wrong code when passing a CLASS to a TYPE
  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 ` burnus at gcc dot gnu.org
  2012-02-03 14:29 ` dominiq at lps dot ens.fr
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: burnus at gcc dot gnu.org @ 2012-02-03 14:25 UTC (permalink / raw)
  To: gcc-bugs

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

Tobias Burnus <burnus at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |burnus at gcc dot gnu.org

--- Comment #1 from Tobias Burnus <burnus at gcc dot gnu.org> 2012-02-03 14:24:29 UTC ---
Ensure that passing CLASS to TYPE also works for polymorphic arrays - and with
ELEMENTAL procedures, cf. also PR 51514.


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

* [Bug fortran/51514] [OOP] Wrong code when passing a CLASS to a TYPE
  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
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: dominiq at lps dot ens.fr @ 2012-02-03 14:29 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Dominique d'Humieres <dominiq at lps dot ens.fr> 2012-02-03 14:28:56 UTC ---
> cf. also PR 51514.

? wrong pr?


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

* [Bug fortran/51514] [OOP] Wrong code when passing a CLASS to a TYPE
  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
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: burnus at gcc dot gnu.org @ 2012-02-03 15:09 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Tobias Burnus <burnus at gcc dot gnu.org> 2012-02-03 15:09:16 UTC ---
(In reply to comment #2)
> > cf. also PR 51514.
> ? wrong pr?

No, why should it be wrong? - Clearly this PR is related to itself...

(I meant PR 50981 - and in particular the summary at PR 50981 comment 36.)


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

* [Bug fortran/51514] [OOP] Wrong code when passing a scalar CLASS to a TYPE
  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
                   ` (2 preceding siblings ...)
  2012-02-03 15:09 ` burnus at gcc dot gnu.org
@ 2012-02-06 11:05 ` burnus at gcc dot gnu.org
  2012-02-06 14:04 ` burnus at gcc dot gnu.org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: burnus at gcc dot gnu.org @ 2012-02-06 11:05 UTC (permalink / raw)
  To: gcc-bugs

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

Tobias Burnus <burnus at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[OOP] Wrong code when       |[OOP] Wrong code when
                   |passing a CLASS to a TYPE   |passing a scalar CLASS to a
                   |                            |TYPE

--- Comment #4 from Tobias Burnus <burnus at gcc dot gnu.org> 2012-02-06 11:04:25 UTC ---
Actually, the issue seems to only affect scalar polymorphic variables.

If the actual argument is a polymorphic array, it works. Both as argument to an
elemental function and to an array dummy argument.


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

* [Bug fortran/51514] [OOP] Wrong code when passing a scalar CLASS to a TYPE
  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
                   ` (3 preceding siblings ...)
  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
  6 siblings, 0 replies; 8+ messages in thread
From: burnus at gcc dot gnu.org @ 2012-02-06 14:04 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Tobias Burnus <burnus at gcc dot gnu.org> 2012-02-06 14:04:29 UTC ---
Created attachment 26583
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=26583
Completely untested/not compiled draft patch

The attached patch is completely untested. It additionally contains some - also
untested - fixes for polymophic coarrays.

Variant:

  subroutine subpr2(x)
    type(foo) :: x
    print *,x%i
    if (x%i /= 55) call abort ()
  end subroutine
  function f()
    class(foo), allocatable :: f
    allocate (f)
    f%i = 55
  end function f
with
  call subpr(f())


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

* [Bug fortran/51514] [OOP] Wrong code when passing a scalar CLASS to a TYPE
  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
                   ` (4 preceding siblings ...)
  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
  6 siblings, 0 replies; 8+ messages in thread
From: burnus at gcc dot gnu.org @ 2012-02-07  8:15 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from Tobias Burnus <burnus at gcc dot gnu.org> 2012-02-07 08:15:28 UTC ---
Author: burnus
Date: Tue Feb  7 08:15:14 2012
New Revision: 183954

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=183954
Log:
2012-02-07  Tobias Burnus  <burnus@net-b.de>

        PR fortran/51514
        * trans-expr.c (gfc_conv_procedure_call): Add _data component
        for calls of scalar CLASS actuals to TYPE dummies.

2012-02-07  Tobias Burnus  <burnus@net-b.de>

        PR fortran/51514
        * gfortran.dg/class_to_type_2.f90: New.


Added:
    trunk/gcc/testsuite/gfortran.dg/class_to_type_2.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/trans-expr.c
    trunk/gcc/testsuite/ChangeLog


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

* [Bug fortran/51514] [OOP] Wrong code when passing a scalar CLASS to a TYPE
  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
                   ` (5 preceding siblings ...)
  2012-02-07  8:15 ` burnus at gcc dot gnu.org
@ 2012-02-07  8:16 ` burnus at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: burnus at gcc dot gnu.org @ 2012-02-07  8:16 UTC (permalink / raw)
  To: gcc-bugs

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

Tobias Burnus <burnus at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |FIXED

--- Comment #7 from Tobias Burnus <burnus at gcc dot gnu.org> 2012-02-07 08:16:24 UTC ---
FIXED on the trunk (4.7).


^ 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).