public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/47565] New: [4.6 Regression][OOP] Segfault with TBP
@ 2011-02-01 8:49 burnus at gcc dot gnu.org
2011-02-01 13:01 ` [Bug fortran/47565] " janus at gcc dot gnu.org
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: burnus at gcc dot gnu.org @ 2011-02-01 8:49 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47565
Summary: [4.6 Regression][OOP] Segfault with TBP
Product: gcc
Version: 4.6.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
Follow up to bug 47455 comment 4.
The following program works with gfortran 4.5 but with gfortran 4.6 it
segfaults at run time at the marked line.
Using a normal function call instead of a TBP call works as well.
==20391== Jump to the invalid address stated on the next line
==20391== at 0x0: ???
==20391== by 0x400C49: MAIN__ (444.f90:27)
==20391== by 0x400C7F: main (444.f90:25)
The dump shows the following difference between working and failing:
- this->_data->y = *find_y ();
+ this->_data->y = *this->_vptr->find_y ();
If one compares this with a working call and POINTER attribute (cf. attachment
23130 to bug 47455 comment 4), one sees:
! Working:
this->_data->x = this->_vptr->find_x (...)
! Failing:
this->_data->y = *this->_vptr->find_y (...)
Note the extra "*".
module class_t
type :: tx
integer, dimension(:), allocatable :: i
end type tx
type :: t
type(tx) :: y
contains
procedure :: calc
procedure, nopass :: find_y
end type t
contains
subroutine calc(this)
class(t) :: this
! WORKS:
! this%y = find_y()
! Segfaults:
this%y = this%find_y() ! Segfault at run time
print *, allocated(this%y%i)
end subroutine calc
function find_y() result(res)
type(tx), allocatable :: res
allocate(res)
end function find_y
end module class_t
use class_t
type(t) :: x
call x%calc()
end
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug fortran/47565] [4.6 Regression][OOP] Segfault with TBP
2011-02-01 8:49 [Bug fortran/47565] New: [4.6 Regression][OOP] Segfault with TBP burnus at gcc dot gnu.org
@ 2011-02-01 13:01 ` janus at gcc dot gnu.org
2011-02-01 13:39 ` janus at gcc dot gnu.org
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: janus at gcc dot gnu.org @ 2011-02-01 13:01 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47565
janus at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2011.02.01 13:00:47
Ever Confirmed|0 |1
--- Comment #1 from janus at gcc dot gnu.org 2011-02-01 13:00:47 UTC ---
Modified test case:
module class_t
contains
function find_y() result(res)
integer, allocatable :: res
print *,"find_y"
allocate(res)
end function
end module
program p
use class_t
type :: t
procedure(find_y), pointer, nopass :: ppc
contains
procedure, nopass :: find_y
end type
class(t), allocatable :: this
integer :: y
allocate(this)
this%ppc => find_y
! (1) ordinary procedure (works)
y = find_y()
print *, y
! (2) procedure pointer component (works)
y = this%ppc()
print *, y
! (3) type-bound procedure (fails)
y = this%find_y() ! segfault at run time
print *, y
end
This shows that the PPC call also works nicely, while the TBP does not.
The dump for all three calls looks ok:
y = *find_y ();
y = *this._data->ppc ();
y = *this._vptr->find_y ();
The problem seems to be that the initialization for the TBP is missing in the
vtab:
static struct __vtype_p_T __vtab_p_T = {._hash=31520549, ._size=8,
._extends=0B, ._def_init=&__def_init_p_T, ._copy=__copy_p_T};
When removing the allocatable attribute of 'find_y', one correctly gets:
static struct __vtype_p_T __vtab_p_T = {._hash=31520549, ._size=8,
._extends=0B, ._def_init=&__def_init_p_T, ._copy=__copy_p_T, .find_y=find_y};
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug fortran/47565] [4.6 Regression][OOP] Segfault with TBP
2011-02-01 8:49 [Bug fortran/47565] New: [4.6 Regression][OOP] Segfault with TBP burnus at gcc dot gnu.org
2011-02-01 13:01 ` [Bug fortran/47565] " janus at gcc dot gnu.org
@ 2011-02-01 13:39 ` janus at gcc dot gnu.org
2011-02-01 15:00 ` janus at gcc dot gnu.org
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: janus at gcc dot gnu.org @ 2011-02-01 13:39 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47565
janus at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |ASSIGNED
AssignedTo|unassigned at gcc dot |janus at gcc dot gnu.org
|gnu.org |
--- Comment #2 from janus at gcc dot gnu.org 2011-02-01 13:39:31 UTC ---
Here is the obvious fix:
Index: trans-expr.c
===================================================================
--- trans-expr.c (revision 169470)
+++ trans-expr.c (working copy)
@@ -4627,7 +4627,7 @@ gfc_conv_structure (gfc_se * se, gfc_expr * expr,
components. Although the latter have a default initializer
of EXPR_NULL,... by default, the static nullify is not needed
since this is done every time we come into scope. */
- if (!c->expr || cm->attr.allocatable)
+ if (!c->expr || (cm->attr.allocatable && cm->attr.flavor !=
FL_PROCEDURE))
continue;
if (strcmp (cm->name, "_size") == 0)
Will commit after regtesting.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug fortran/47565] [4.6 Regression][OOP] Segfault with TBP
2011-02-01 8:49 [Bug fortran/47565] New: [4.6 Regression][OOP] Segfault with TBP burnus at gcc dot gnu.org
2011-02-01 13:01 ` [Bug fortran/47565] " janus at gcc dot gnu.org
2011-02-01 13:39 ` janus at gcc dot gnu.org
@ 2011-02-01 15:00 ` janus at gcc dot gnu.org
2011-02-01 15:01 ` janus at gcc dot gnu.org
2011-02-02 18:33 ` dnovillo at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: janus at gcc dot gnu.org @ 2011-02-01 15:00 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47565
--- Comment #3 from janus at gcc dot gnu.org 2011-02-01 14:59:45 UTC ---
Author: janus
Date: Tue Feb 1 14:59:40 2011
New Revision: 169480
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=169480
Log:
2011-02-01 Janus Weil <janus@gcc.gnu.org>
PR fortran/47565
* trans-expr.c (gfc_conv_structure): Handle constructors for procedure
pointer components with allocatable result.
2011-02-01 Janus Weil <janus@gcc.gnu.org>
PR fortran/47565
* gfortran.dg/typebound_call_20.f03: New.
Added:
trunk/gcc/testsuite/gfortran.dg/typebound_call_20.f03
Modified:
trunk/gcc/fortran/ChangeLog
trunk/gcc/fortran/trans-expr.c
trunk/gcc/testsuite/ChangeLog
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug fortran/47565] [4.6 Regression][OOP] Segfault with TBP
2011-02-01 8:49 [Bug fortran/47565] New: [4.6 Regression][OOP] Segfault with TBP burnus at gcc dot gnu.org
` (2 preceding siblings ...)
2011-02-01 15:00 ` janus at gcc dot gnu.org
@ 2011-02-01 15:01 ` janus at gcc dot gnu.org
2011-02-02 18:33 ` dnovillo at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: janus at gcc dot gnu.org @ 2011-02-01 15:01 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47565
janus at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution| |FIXED
--- Comment #4 from janus at gcc dot gnu.org 2011-02-01 15:01:22 UTC ---
Fixed with r169480. Closing.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug fortran/47565] [4.6 Regression][OOP] Segfault with TBP
2011-02-01 8:49 [Bug fortran/47565] New: [4.6 Regression][OOP] Segfault with TBP burnus at gcc dot gnu.org
` (3 preceding siblings ...)
2011-02-01 15:01 ` janus at gcc dot gnu.org
@ 2011-02-02 18:33 ` dnovillo at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: dnovillo at gcc dot gnu.org @ 2011-02-02 18:33 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47565
--- Comment #5 from Diego Novillo <dnovillo at gcc dot gnu.org> 2011-02-02 18:15:41 UTC ---
Author: dnovillo
Date: Wed Feb 2 18:15:33 2011
New Revision: 169746
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=169746
Log:
2011-02-01 Janus Weil <janus@gcc.gnu.org>
PR fortran/47565
* trans-expr.c (gfc_conv_structure): Handle constructors for procedure
pointer components with allocatable result.
2011-02-01 Janus Weil <janus@gcc.gnu.org>
PR fortran/47565
* gfortran.dg/typebound_call_20.f03: New.
Added:
branches/google/integration/gcc/testsuite/gfortran.dg/typebound_call_20.f03
Modified:
branches/google/integration/gcc/fortran/ChangeLog
branches/google/integration/gcc/fortran/trans-expr.c
branches/google/integration/gcc/testsuite/ChangeLog
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2011-02-02 18:33 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-02-01 8:49 [Bug fortran/47565] New: [4.6 Regression][OOP] Segfault with TBP burnus at gcc dot gnu.org
2011-02-01 13:01 ` [Bug fortran/47565] " janus at gcc dot gnu.org
2011-02-01 13:39 ` janus at gcc dot gnu.org
2011-02-01 15:00 ` janus at gcc dot gnu.org
2011-02-01 15:01 ` janus at gcc dot gnu.org
2011-02-02 18:33 ` dnovillo 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).