* [Bug fortran/42104] Segmentation fault with procedure pointer component
2009-11-19 5:52 [Bug fortran/42104] New: Segmentation fault with procedure pointer component m dot a dot hulsen at tue dot nl
@ 2009-11-19 5:53 ` m dot a dot hulsen at tue dot nl
2009-11-19 6:08 ` m dot a dot hulsen at tue dot nl
` (10 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: m dot a dot hulsen at tue dot nl @ 2009-11-19 5:53 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from m dot a dot hulsen at tue dot nl 2009-11-19 05:52 -------
Created an attachment (id=19042)
--> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=19042&action=view)
source exposing the problem
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42104
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug fortran/42104] Segmentation fault with procedure pointer component
2009-11-19 5:52 [Bug fortran/42104] New: Segmentation fault with procedure pointer component m dot a dot hulsen at tue dot nl
2009-11-19 5:53 ` [Bug fortran/42104] " m dot a dot hulsen at tue dot nl
@ 2009-11-19 6:08 ` m dot a dot hulsen at tue dot nl
2009-11-19 10:45 ` [Bug fortran/42104] [F03] runtime segfault " janus at gcc dot gnu dot org
` (9 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: m dot a dot hulsen at tue dot nl @ 2009-11-19 6:08 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from m dot a dot hulsen at tue dot nl 2009-11-19 06:08 -------
Created an attachment (id=19043)
--> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=19043&action=view)
simplified (removed pp in main)
Removed the pp in the main program, because ifort does not seem to like it.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42104
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug fortran/42104] [F03] runtime segfault with procedure pointer component
2009-11-19 5:52 [Bug fortran/42104] New: Segmentation fault with procedure pointer component m dot a dot hulsen at tue dot nl
2009-11-19 5:53 ` [Bug fortran/42104] " m dot a dot hulsen at tue dot nl
2009-11-19 6:08 ` m dot a dot hulsen at tue dot nl
@ 2009-11-19 10:45 ` janus at gcc dot gnu dot org
2009-11-19 11:57 ` janus at gcc dot gnu dot org
` (8 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: janus at gcc dot gnu dot org @ 2009-11-19 10:45 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from janus at gcc dot gnu dot org 2009-11-19 10:45 -------
Confirmed.
--
janus at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever Confirmed|0 |1
Keywords| |wrong-code
Last reconfirmed|0000-00-00 00:00:00 |2009-11-19 10:45:21
date| |
Summary|Segmentation fault with |[F03] runtime segfault with
|procedure pointer component |procedure pointer component
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42104
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug fortran/42104] [F03] runtime segfault with procedure pointer component
2009-11-19 5:52 [Bug fortran/42104] New: Segmentation fault with procedure pointer component m dot a dot hulsen at tue dot nl
` (2 preceding siblings ...)
2009-11-19 10:45 ` [Bug fortran/42104] [F03] runtime segfault " janus at gcc dot gnu dot org
@ 2009-11-19 11:57 ` janus at gcc dot gnu dot org
2009-11-19 13:25 ` pault at gcc dot gnu dot org
` (7 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: janus at gcc dot gnu dot org @ 2009-11-19 11:57 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from janus at gcc dot gnu dot org 2009-11-19 11:57 -------
Let's have a look at the dump for the test case in comment #2.
The call to 'func' is translated to:
real(kind=4) D.1568;
struct array1_real(kind=4) parm.7;
static real(kind=4) A.6[2] = {1.00000001490116119384765625e-1,
1.00000001490116119384765625e-1};
static integer(kind=4) C.1562 = 3;
parm.7.dtype = 281;
parm.7.dim[0].lbound = 1;
parm.7.dim[0].ubound = 2;
parm.7.dim[0].stride = 1;
parm.7.data = (void *) &A.6[0];
parm.7.offset = 0;
D.1568 = func (&C.1562, &parm.7);
The PPC call to 'funcp%p' looks simlar, except for:
D.1576 = _gfortran_internal_pack (&parm.10);
D.1578 = funcp.p (&C.1570, D.1576);
(i.e. it has an additional _gfortran_internal_pack).
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42104
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug fortran/42104] [F03] runtime segfault with procedure pointer component
2009-11-19 5:52 [Bug fortran/42104] New: Segmentation fault with procedure pointer component m dot a dot hulsen at tue dot nl
` (3 preceding siblings ...)
2009-11-19 11:57 ` janus at gcc dot gnu dot org
@ 2009-11-19 13:25 ` pault at gcc dot gnu dot org
2009-11-19 21:09 ` janus at gcc dot gnu dot org
` (6 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: pault at gcc dot gnu dot org @ 2009-11-19 13:25 UTC (permalink / raw)
To: gcc-bugs
------- Comment #5 from pault at gcc dot gnu dot org 2009-11-19 13:25 -------
Martien,
Thank you very much for this report.
I have assigned it to myself and have a non-regtested fix:
As remarked by Janus, the problem is with the array argument. The code
produced for the proc_pointer call is
parm.13.dtype = 281;
parm.13.dim[0].lbound = 1;
parm.13.dim[0].ubound = 2;
parm.13.dim[0].stride = 1;
parm.13.data = (void *) &A.12[0];
parm.13.offset = 0;
D.1402 = _gfortran_internal_pack (&parm.13);
D.1404 = funcp.p (&C.1396, D.1402);
The internal_pack should not be there, since the assumed shape formal argument
requires that a descriptor be passed. This, in its turn comes about because
the symbol funcp is not marked as being always_explicit.
(In fact, he and I had a mid-air collision on this!)
The fix is to make use of the fact a proc_pointer component call is already
detected and can be used to suppress the internal_pack. Thusly:
Index: gcc/fortran/trans-expr.c
===================================================================
--- gcc/fortran/trans-expr.c (revision 153651)
+++ gcc/fortran/trans-expr.c (working copy)
@@ -2918,7 +2918,7 @@
f = (fsym != NULL)
&& !(fsym->attr.pointer || fsym->attr.allocatable)
&& fsym->as->type != AS_ASSUMED_SHAPE;
- f = f || !sym->attr.always_explicit;
+ f = f || (!sym->attr.always_explicit && !comp);
if (e->expr_type == EXPR_VARIABLE
&& is_subref_array (e))
This fixes the PR but has not been regtested. I will do this tonight. If all
is well, I will commit as obvious, although your OK would be helpful, Janus!
Paul
--
pault at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|unassigned at gcc dot gnu |pault at gcc dot gnu dot org
|dot org |
Severity|major |normal
Status|NEW |ASSIGNED
Last reconfirmed|2009-11-19 10:45:21 |2009-11-19 13:25:32
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42104
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug fortran/42104] [F03] runtime segfault with procedure pointer component
2009-11-19 5:52 [Bug fortran/42104] New: Segmentation fault with procedure pointer component m dot a dot hulsen at tue dot nl
` (4 preceding siblings ...)
2009-11-19 13:25 ` pault at gcc dot gnu dot org
@ 2009-11-19 21:09 ` janus at gcc dot gnu dot org
2009-11-19 21:59 ` janus at gcc dot gnu dot org
` (5 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: janus at gcc dot gnu dot org @ 2009-11-19 21:09 UTC (permalink / raw)
To: gcc-bugs
------- Comment #6 from janus at gcc dot gnu dot org 2009-11-19 21:09 -------
(In reply to comment #5)
> The fix is to make use of the fact a proc_pointer component call is already
> detected and can be used to suppress the internal_pack. Thusly:
>
> Index: gcc/fortran/trans-expr.c
> ===================================================================
> --- gcc/fortran/trans-expr.c (revision 153651)
> +++ gcc/fortran/trans-expr.c (working copy)
> @@ -2918,7 +2918,7 @@
> f = (fsym != NULL)
> && !(fsym->attr.pointer || fsym->attr.allocatable)
> && fsym->as->type != AS_ASSUMED_SHAPE;
> - f = f || !sym->attr.always_explicit;
> + f = f || (!sym->attr.always_explicit && !comp);
>
> if (e->expr_type == EXPR_VARIABLE
> && is_subref_array (e))
>
> This fixes the PR but has not been regtested. I will do this tonight. If all
> is well, I will commit as obvious, although your OK would be helpful, Janus!
The question is if you want to do this for *all* PPCs. It seems the
'always_explicit' flag is correctly set for PPCs (by the same criteria as for
normal procedures). Therefore I would propose the following:
Index: gcc/fortran/trans-expr.c
===================================================================
--- gcc/fortran/trans-expr.c (revision 154327)
+++ gcc/fortran/trans-expr.c (working copy)
@@ -2979,7 +2979,10 @@ gfc_conv_procedure_call (gfc_se * se, gfc_symbol *
f = (fsym != NULL)
&& !(fsym->attr.pointer || fsym->attr.allocatable)
&& fsym->as->type != AS_ASSUMED_SHAPE;
- f = f || !sym->attr.always_explicit;
+ if (comp)
+ f = f || !comp->attr.always_explicit;
+ else
+ f = f || !sym->attr.always_explicit;
if (e->expr_type == EXPR_VARIABLE
&& is_subref_array (e))
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42104
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug fortran/42104] [F03] runtime segfault with procedure pointer component
2009-11-19 5:52 [Bug fortran/42104] New: Segmentation fault with procedure pointer component m dot a dot hulsen at tue dot nl
` (5 preceding siblings ...)
2009-11-19 21:09 ` janus at gcc dot gnu dot org
@ 2009-11-19 21:59 ` janus at gcc dot gnu dot org
2009-11-20 4:59 ` pault at gcc dot gnu dot org
` (4 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: janus at gcc dot gnu dot org @ 2009-11-19 21:59 UTC (permalink / raw)
To: gcc-bugs
------- Comment #7 from janus at gcc dot gnu dot org 2009-11-19 21:59 -------
(In reply to comment #6)
> Index: gcc/fortran/trans-expr.c
> ===================================================================
> --- gcc/fortran/trans-expr.c (revision 154327)
> +++ gcc/fortran/trans-expr.c (working copy)
> @@ -2979,7 +2979,10 @@ gfc_conv_procedure_call (gfc_se * se, gfc_symbol *
> f = (fsym != NULL)
> && !(fsym->attr.pointer || fsym->attr.allocatable)
> && fsym->as->type != AS_ASSUMED_SHAPE;
> - f = f || !sym->attr.always_explicit;
> + if (comp)
> + f = f || !comp->attr.always_explicit;
> + else
> + f = f || !sym->attr.always_explicit;
>
> if (e->expr_type == EXPR_VARIABLE
> && is_subref_array (e))
This patch makes the test case work and regtests without regressions. Paul,
should I commit it or do you prefer your version?
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42104
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug fortran/42104] [F03] runtime segfault with procedure pointer component
2009-11-19 5:52 [Bug fortran/42104] New: Segmentation fault with procedure pointer component m dot a dot hulsen at tue dot nl
` (6 preceding siblings ...)
2009-11-19 21:59 ` janus at gcc dot gnu dot org
@ 2009-11-20 4:59 ` pault at gcc dot gnu dot org
2009-11-20 6:43 ` pault at gcc dot gnu dot org
` (3 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: pault at gcc dot gnu dot org @ 2009-11-20 4:59 UTC (permalink / raw)
To: gcc-bugs
------- Comment #8 from pault at gcc dot gnu dot org 2009-11-20 04:59 -------
(In reply to comment #7)
Janus,
That version is a very good suggestion - thanks. I am set up to apply the
patch, so, although component procedure pointers is one of your
specialisations, I can efficiently get on and do it.
I will take it that this is an OK from you.
Cheers
Paul
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42104
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug fortran/42104] [F03] runtime segfault with procedure pointer component
2009-11-19 5:52 [Bug fortran/42104] New: Segmentation fault with procedure pointer component m dot a dot hulsen at tue dot nl
` (7 preceding siblings ...)
2009-11-20 4:59 ` pault at gcc dot gnu dot org
@ 2009-11-20 6:43 ` pault at gcc dot gnu dot org
2009-11-20 6:57 ` janus at gcc dot gnu dot org
` (2 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: pault at gcc dot gnu dot org @ 2009-11-20 6:43 UTC (permalink / raw)
To: gcc-bugs
------- Comment #9 from pault at gcc dot gnu dot org 2009-11-20 06:43 -------
Subject: Bug 42104
Author: pault
Date: Fri Nov 20 06:43:13 2009
New Revision: 154358
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=154358
Log:
2009-11-20 Paul Thomas <pault@gcc.gnu.org>
Janus Weil <janus@gcc.gnu.org>
PR fortran/42104
* trans-expr.c (gfc_conv_procedure_call): If procedure pointer
component call, use the component's 'always_explicit' attr
for array arguments.
2009-11-20 Paul Thomas <pault@gcc.gnu.org>
Janus Weil <janus@gcc.gnu.org>
PR fortran/42104
* gfortran.dg/proc_ptr_comp_23.f90 : New test.
Added:
trunk/gcc/testsuite/gfortran.dg/proc_ptr_comp_23.f90
Modified:
trunk/gcc/fortran/ChangeLog
trunk/gcc/fortran/trans-expr.c
trunk/gcc/testsuite/ChangeLog
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42104
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug fortran/42104] [F03] runtime segfault with procedure pointer component
2009-11-19 5:52 [Bug fortran/42104] New: Segmentation fault with procedure pointer component m dot a dot hulsen at tue dot nl
` (8 preceding siblings ...)
2009-11-20 6:43 ` pault at gcc dot gnu dot org
@ 2009-11-20 6:57 ` janus at gcc dot gnu dot org
2009-11-20 7:58 ` pault at gcc dot gnu dot org
2009-12-03 5:33 ` pault at gcc dot gnu dot org
11 siblings, 0 replies; 13+ messages in thread
From: janus at gcc dot gnu dot org @ 2009-11-20 6:57 UTC (permalink / raw)
To: gcc-bugs
------- Comment #10 from janus at gcc dot gnu dot org 2009-11-20 06:57 -------
(In reply to comment #8)
> I will take it that this is an OK from you.
Sure thing. Thanks for committing.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42104
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug fortran/42104] [F03] runtime segfault with procedure pointer component
2009-11-19 5:52 [Bug fortran/42104] New: Segmentation fault with procedure pointer component m dot a dot hulsen at tue dot nl
` (9 preceding siblings ...)
2009-11-20 6:57 ` janus at gcc dot gnu dot org
@ 2009-11-20 7:58 ` pault at gcc dot gnu dot org
2009-12-03 5:33 ` pault at gcc dot gnu dot org
11 siblings, 0 replies; 13+ messages in thread
From: pault at gcc dot gnu dot org @ 2009-11-20 7:58 UTC (permalink / raw)
To: gcc-bugs
------- Comment #11 from pault at gcc dot gnu dot org 2009-11-20 07:57 -------
Many thanks for the report.
Fixed on trunk
Paul
--
pault at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution| |FIXED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42104
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug fortran/42104] [F03] runtime segfault with procedure pointer component
2009-11-19 5:52 [Bug fortran/42104] New: Segmentation fault with procedure pointer component m dot a dot hulsen at tue dot nl
` (10 preceding siblings ...)
2009-11-20 7:58 ` pault at gcc dot gnu dot org
@ 2009-12-03 5:33 ` pault at gcc dot gnu dot org
11 siblings, 0 replies; 13+ messages in thread
From: pault at gcc dot gnu dot org @ 2009-12-03 5:33 UTC (permalink / raw)
To: gcc-bugs
------- Comment #12 from pault at gcc dot gnu dot org 2009-12-03 05:33 -------
Subject: Bug 42104
Author: pault
Date: Thu Dec 3 05:32:58 2009
New Revision: 154935
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=154935
Log:
2009-12-03 Paul Thomas <pault@gcc.gnu.org>
Janus Weil <janus@gcc.gnu.org>
PR fortran/42104
* trans-expr.c (select_class_proc): Remove function.
(conv_function_val): Delete reference to previous.
(gfc_conv_derived_to_class): Add second argument to the call to
gfc_find_derived_vtab.
(gfc_conv_structure): Exclude proc_pointer components when
accessing $data field of class objects.
(gfc_trans_assign_vtab_procs): New function.
(gfc_trans_class_assign): Add second argument to the call to
gfc_find_derived_vtab.
* symbol.c (gfc_build_class_symbol): Add delayed_vtab arg and
implement holding off searching for the vptr derived type.
(add_proc_component): New function.
(add_proc_comps): New function.
(add_procs_to_declared_vtab1): New function.
(copy_vtab_proc_comps): New function.
(add_procs_to_declared_vtab): New function.
(void add_generic_specifics): New function.
(add_generics_to_declared_vtab): New function.
(gfc_find_derived_vtab): Add second argument to the call to
gfc_find_derived_vtab. Add the calls to
add_procs_to_declared_vtab and add_generics_to_declared_vtab.
* decl.c (build_sym, build_struct): Use new arg in calls to
gfc_build_class_symbol.
* gfortran.h : Add vtype bitfield to symbol_attr. Remove the
definition of struct gfc_class_esym_list. Modify prototypes
of gfc_build_class_symbol and gfc_find_derived_vtab.
* trans-stmt.c (gfc_trans_allocate): Add second argument to the
call to gfc_find_derived_vtab.
* module.c : Add the vtype attribute.
* trans.h : Add prototype for gfc_trans_assign_vtab_procs.
* resolve.c (resolve_typebound_generic_call): Add second arg
to pass along the generic name for class methods.
(resolve_typebound_call): The same.
(resolve_compcall): Use the second arg to carry the generic
name from the above. Remove the reference to class_esym.
(check_members, check_class_members, resolve_class_esym,
hash_value_expr): Remove functions.
(resolve_class_compcall, resolve_class_typebound_call): Modify
to use vtable rather than member by member calls.
(gfc_resolve_expr): Modify second arg in call to
resolve_compcall.
(resolve_select_type): Add second arg in call to
gfc_find_derived_vtab.
(resolve_code): Add second arg in call resolve_typebound_call.
(resolve_fl_derived): Exclude vtypes from check for late
procedure definitions. Likewise for checking of explicit
interface and checking of pass arg.
* iresolve.c (gfc_resolve_extends_type_of): Add second arg in
calls to gfc_find_derived_vtab.
* match.c (select_type_set_tmp): Use new arg in call to
gfc_build_class_symbol.
* trans-decl.c (gfc_get_symbol_decl): Complete vtable if
necessary.
* parse.c (endType): Finish incomplete classes.
2009-12-03 Paul Thomas <pault@gcc.gnu.org>
Janus Weil <janus@gcc.gnu.org>
PR fortran/41829
* gfortran.dg/dynamic_dispatch_5.f03 : Change to "run".
* gfortran.dg/dynamic_dispatch_6.f03 : New test.
* gfortran.dg/dynamic_dispatch_7.f03 : New test.
Added:
branches/fortran-dev/gcc/testsuite/gfortran.dg/dynamic_dispatch_6.f03
branches/fortran-dev/gcc/testsuite/gfortran.dg/dynamic_dispatch_7.f03
Modified:
branches/fortran-dev/gcc/fortran/ChangeLog.fortran-dev
branches/fortran-dev/gcc/fortran/decl.c
branches/fortran-dev/gcc/fortran/gfortran.h
branches/fortran-dev/gcc/fortran/iresolve.c
branches/fortran-dev/gcc/fortran/match.c
branches/fortran-dev/gcc/fortran/module.c
branches/fortran-dev/gcc/fortran/parse.c
branches/fortran-dev/gcc/fortran/resolve.c
branches/fortran-dev/gcc/fortran/symbol.c
branches/fortran-dev/gcc/fortran/trans-decl.c
branches/fortran-dev/gcc/fortran/trans-expr.c
branches/fortran-dev/gcc/fortran/trans-stmt.c
branches/fortran-dev/gcc/fortran/trans.h
branches/fortran-dev/gcc/testsuite/ChangeLog.fortran-dev
branches/fortran-dev/gcc/testsuite/gfortran.dg/dynamic_dispatch_5.f03
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42104
^ permalink raw reply [flat|nested] 13+ messages in thread