public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/56845] New: [OOP] _vptr not set to declared type for CLASS + SAVE
@ 2013-04-04 19:08 burnus at gcc dot gnu.org
  2013-04-04 20:15 ` [Bug fortran/56845] " janus at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: burnus at gcc dot gnu.org @ 2013-04-04 19:08 UTC (permalink / raw)
  To: gcc-bugs


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

             Bug #: 56845
           Summary: [OOP] _vptr not set to declared type for CLASS + SAVE
    Classification: Unclassified
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: burnus@gcc.gnu.org
                CC: janus@gcc.gnu.org


The program below fails at run time. Unallocated the class should match the
declared type - but it is never set with SAVE.


The dump of the following program shows:
  static struct __class_m_T_a y = {};
Expected:
  static struct __class_m_T_a y = { ._data = 0B, ._vptr = &__vtab_m_T};


module m
type t
integer ::a
end type t
contains
subroutine sub
  type(t), save, allocatable :: x
  class(t), save,allocatable :: y
  if (.not. same_type_as(x,y)) call abort()
end subroutine sub
subroutine sub2
  type(t), save, allocatable :: a(:)
  class(t), save,allocatable :: b(:)
  if (.not. same_type_as(a,b)) call abort()
end subroutine sub2
end module m

use m
call sub()
call sub2()
end


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

* [Bug fortran/56845] [OOP] _vptr not set to declared type for CLASS + SAVE
  2013-04-04 19:08 [Bug fortran/56845] New: [OOP] _vptr not set to declared type for CLASS + SAVE burnus at gcc dot gnu.org
@ 2013-04-04 20:15 ` janus at gcc dot gnu.org
  2013-04-04 21:01 ` janus at gcc dot gnu.org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: janus at gcc dot gnu.org @ 2013-04-04 20:15 UTC (permalink / raw)
  To: gcc-bugs


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

--- Comment #1 from janus at gcc dot gnu.org 2013-04-04 20:15:07 UTC ---
Huh, funny. I thought we were doing this already.

Also there is a piece of code in gfc_trans_deferred_vars (trans-decl.c) which
claims to do exactly this (AFAICS). No idea why it is not in effect.


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

* [Bug fortran/56845] [OOP] _vptr not set to declared type for CLASS + SAVE
  2013-04-04 19:08 [Bug fortran/56845] New: [OOP] _vptr not set to declared type for CLASS + SAVE burnus at gcc dot gnu.org
  2013-04-04 20:15 ` [Bug fortran/56845] " janus at gcc dot gnu.org
@ 2013-04-04 21:01 ` janus at gcc dot gnu.org
  2013-04-04 21:24 ` janus at gcc dot gnu.org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: janus at gcc dot gnu.org @ 2013-04-04 21:01 UTC (permalink / raw)
  To: gcc-bugs


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

--- Comment #2 from janus at gcc dot gnu.org 2013-04-04 21:01:19 UTC ---
(In reply to comment #1)
> Also there is a piece of code in gfc_trans_deferred_vars (trans-decl.c) which
> claims to do exactly this (AFAICS). No idea why it is not in effect.

That's easily answered: Because it is guarded by an "if (!sym->attr.save)".


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

* [Bug fortran/56845] [OOP] _vptr not set to declared type for CLASS + SAVE
  2013-04-04 19:08 [Bug fortran/56845] New: [OOP] _vptr not set to declared type for CLASS + SAVE burnus at gcc dot gnu.org
  2013-04-04 20:15 ` [Bug fortran/56845] " janus at gcc dot gnu.org
  2013-04-04 21:01 ` janus at gcc dot gnu.org
@ 2013-04-04 21:24 ` janus at gcc dot gnu.org
  2013-04-05  8:44 ` burnus at gcc dot gnu.org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: janus at gcc dot gnu.org @ 2013-04-04 21:24 UTC (permalink / raw)
  To: gcc-bugs


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

janus at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2013-04-04
     Ever Confirmed|0                           |1

--- Comment #3 from janus at gcc dot gnu.org 2013-04-04 21:24:12 UTC ---
(In reply to comment #2)
> (In reply to comment #1)
> > Also there is a piece of code in gfc_trans_deferred_vars (trans-decl.c) which
> > claims to do exactly this (AFAICS). No idea why it is not in effect.
> 
> That's easily answered: Because it is guarded by an "if (!sym->attr.save)".

Also it can not be used for SAVEd variables, because it would set the vptr on
each call of the subroutine (which is of course not what we want).


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

* [Bug fortran/56845] [OOP] _vptr not set to declared type for CLASS + SAVE
  2013-04-04 19:08 [Bug fortran/56845] New: [OOP] _vptr not set to declared type for CLASS + SAVE burnus at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2013-04-04 21:24 ` janus at gcc dot gnu.org
@ 2013-04-05  8:44 ` burnus at gcc dot gnu.org
  2013-04-12  7:42 ` burnus at gcc dot gnu.org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: burnus at gcc dot gnu.org @ 2013-04-05  8:44 UTC (permalink / raw)
  To: gcc-bugs


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

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

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

--- Comment #4 from Tobias Burnus <burnus at gcc dot gnu.org> 2013-04-05 08:43:58 UTC ---
(In reply to comment #1)
> Huh, funny. I thought we were doing this already.
> 
> Also there is a piece of code in gfc_trans_deferred_vars (trans-decl.c) which
> claims to do exactly this (AFAICS). No idea why it is not in effect.

For ALLOCATABLE,SAVE the array itself is initialized via a call to
trans-array.c's gfc_build_null_descriptor.


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

* [Bug fortran/56845] [OOP] _vptr not set to declared type for CLASS + SAVE
  2013-04-04 19:08 [Bug fortran/56845] New: [OOP] _vptr not set to declared type for CLASS + SAVE burnus at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2013-04-12  7:42 ` burnus at gcc dot gnu.org
@ 2013-04-12  7:42 ` burnus at gcc dot gnu.org
  2013-04-12  9:23 ` burnus at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: burnus at gcc dot gnu.org @ 2013-04-12  7:42 UTC (permalink / raw)
  To: gcc-bugs


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

--- Comment #5 from Tobias Burnus <burnus at gcc dot gnu.org> 2013-04-12 07:42:30 UTC ---
Author: burnus
Date: Fri Apr 12 07:41:50 2013
New Revision: 197844

URL: http://gcc.gnu.org/viewcvs?rev=197844&root=gcc&view=rev
Log:
2013-04-12  Tobias Burnus  <burnus@net-b.de>

        PR fortran/56845
        * trans-decl.c (gfc_trans_deferred_vars): Set _vptr for
        allocatable static BT_CLASS.
        * trans-expr.c (gfc_class_set_static_fields): New function.
        * trans.h (gfc_class_set_static_fields): New prototype.

2013-04-12  Tobias Burnus  <burnus@net-b.de>

        PR fortran/56845
        * gfortran.dg/class_allocate_14.f90: New.
        * gfortran.dg/coarray_lib_alloc_2.f90: Update
        * scan-tree-dump-times.
        * gfortran.dg/coarray_lib_alloc_3.f90: New.


Added:
    trunk/gcc/testsuite/gfortran.dg/class_allocate_14.f90
    trunk/gcc/testsuite/gfortran.dg/coarray_lib_alloc_3.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/trans-decl.c
    trunk/gcc/fortran/trans-expr.c
    trunk/gcc/fortran/trans.h
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/gfortran.dg/coarray_lib_alloc_2.f90


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

* [Bug fortran/56845] [OOP] _vptr not set to declared type for CLASS + SAVE
  2013-04-04 19:08 [Bug fortran/56845] New: [OOP] _vptr not set to declared type for CLASS + SAVE burnus at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2013-04-05  8:44 ` burnus at gcc dot gnu.org
@ 2013-04-12  7:42 ` burnus at gcc dot gnu.org
  2013-04-12  7:42 ` burnus at gcc dot gnu.org
  2013-04-12  9:23 ` burnus at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: burnus at gcc dot gnu.org @ 2013-04-12  7:42 UTC (permalink / raw)
  To: gcc-bugs


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

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

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

--- Comment #6 from Tobias Burnus <burnus at gcc dot gnu.org> 2013-04-12 07:42:52 UTC ---
FIXED on the 4.9 trunk


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

* [Bug fortran/56845] [OOP] _vptr not set to declared type for CLASS + SAVE
  2013-04-04 19:08 [Bug fortran/56845] New: [OOP] _vptr not set to declared type for CLASS + SAVE burnus at gcc dot gnu.org
                   ` (5 preceding siblings ...)
  2013-04-12  7:42 ` burnus at gcc dot gnu.org
@ 2013-04-12  9:23 ` burnus at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: burnus at gcc dot gnu.org @ 2013-04-12  9:23 UTC (permalink / raw)
  To: gcc-bugs


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

--- Comment #7 from Tobias Burnus <burnus at gcc dot gnu.org> 2013-04-12 09:23:20 UTC ---
FIXED an issue created by the previous patch, cf.
http://gcc.gnu.org/ml/fortran/2013-04/msg00116.html

 * * *

Author: burnus
Date: Fri Apr 12 08:54:15 2013
New Revision: 197848

URL: http://gcc.gnu.org/viewcvs?rev=197848&root=gcc&view=rev
Log:
2013-04-12  Tobias Burnus  <burnus@net-b.de>

        PR fortran/56845
        * trans-decl.c (gfc_trans_deferred_vars): Restrict
        static CLASS init to SAVE and -fno-automatic.

2013-04-12  Tobias Burnus  <burnus@net-b.de>

        PR fortran/56845
        * gfortran.dg/class_allocate_15.f90: New.

        Revert:
        2013-04-12  Tobias Burnus  <burnus@net-b.de>

        * gfortran.dg/coarray_lib_alloc_2.f90: Update
        scan-tree-dump-times.


Added:
    trunk/gcc/testsuite/gfortran.dg/class_allocate_15.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/trans-decl.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/gfortran.dg/coarray_lib_alloc_2.f90


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

end of thread, other threads:[~2013-04-12  9:23 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-04-04 19:08 [Bug fortran/56845] New: [OOP] _vptr not set to declared type for CLASS + SAVE burnus at gcc dot gnu.org
2013-04-04 20:15 ` [Bug fortran/56845] " janus at gcc dot gnu.org
2013-04-04 21:01 ` janus at gcc dot gnu.org
2013-04-04 21:24 ` janus at gcc dot gnu.org
2013-04-05  8:44 ` burnus at gcc dot gnu.org
2013-04-12  7:42 ` burnus at gcc dot gnu.org
2013-04-12  7:42 ` burnus at gcc dot gnu.org
2013-04-12  9:23 ` 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).