public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/37253] New: Segmentation fault with procedure pointer
@ 2008-08-27 10:51 dominiq at lps dot ens dot fr
2008-08-27 12:37 ` [Bug fortran/37253] " janus at gcc dot gnu dot org
` (6 more replies)
0 siblings, 7 replies; 8+ messages in thread
From: dominiq at lps dot ens dot fr @ 2008-08-27 10:51 UTC (permalink / raw)
To: gcc-bugs
The following code
module myMod
CONTAINS
real function proc3( arg1 )
integer :: arg1
proc3 = arg1+7
end function proc3
subroutine proc4( arg1 )
procedure(real), pointer :: arg1
print*, 'the func: ', arg1(0)
end subroutine proc4
end module myMod
program myProg
use myMod
PROCEDURE (real), POINTER :: p => NULL()
p => proc3
print*, 'the func: ', p(0)
call proc4( p )
end program myProg
gives a segmentation fault at run time:
[ibook-dhum] f90/bug% a.out
the func: 7.0000000
Segmentation fault
--
Summary: Segmentation fault with procedure pointer
Product: gcc
Version: 4.4.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: dominiq at lps dot ens dot fr
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37253
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/37253] Segmentation fault with procedure pointer
2008-08-27 10:51 [Bug fortran/37253] New: Segmentation fault with procedure pointer dominiq at lps dot ens dot fr
@ 2008-08-27 12:37 ` janus at gcc dot gnu dot org
2008-08-27 20:31 ` burnus at gcc dot gnu dot org
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: janus at gcc dot gnu dot org @ 2008-08-27 12:37 UTC (permalink / raw)
To: gcc-bugs
--
janus at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |janus at gcc dot gnu dot org
Status|UNCONFIRMED |NEW
Ever Confirmed|0 |1
Last reconfirmed|0000-00-00 00:00:00 |2008-08-27 12:35:40
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37253
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/37253] Segmentation fault with procedure pointer
2008-08-27 10:51 [Bug fortran/37253] New: Segmentation fault with procedure pointer dominiq at lps dot ens dot fr
2008-08-27 12:37 ` [Bug fortran/37253] " janus at gcc dot gnu dot org
@ 2008-08-27 20:31 ` burnus at gcc dot gnu dot org
2008-08-27 20:34 ` burnus at gcc dot gnu dot org
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: burnus at gcc dot gnu dot org @ 2008-08-27 20:31 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from burnus at gcc dot gnu dot org 2008-08-27 20:30 -------
call proc4( p )
should transfer to the tree code as
proc4(&p)
(procpointer passed by reference) but it is actually
proc(p)
The latter is OK for a PROCEDURE dummy argument but nor for a PROCEDURE POINTER
dummy argument.
I know we came across the pass-by-refence issue before when implementing
procpointers (cf. proc_ptr_7.f90). Why does not not work in this case? In
proc_ptr_7.f90 we have:
procedure(Integer(c_int)), pointer :: ptr
call foo(ptr)
with
subroutine foo(a)
procedure(integer(c_int)), pointer :: a
which produces:
foo (&ptr);
What is different here?
* * *
I think there is some issue with saving the information in the module. If one
moves proc4 to the main program (via contains) then it work, i.e. the
procpointer information is lost.
--
burnus at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |burnus at gcc dot gnu dot
| |org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37253
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/37253] Segmentation fault with procedure pointer
2008-08-27 10:51 [Bug fortran/37253] New: Segmentation fault with procedure pointer dominiq at lps dot ens dot fr
2008-08-27 12:37 ` [Bug fortran/37253] " janus at gcc dot gnu dot org
2008-08-27 20:31 ` burnus at gcc dot gnu dot org
@ 2008-08-27 20:34 ` burnus at gcc dot gnu dot org
2008-08-27 21:12 ` janus at gcc dot gnu dot org
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: burnus at gcc dot gnu dot org @ 2008-08-27 20:34 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from burnus at gcc dot gnu dot org 2008-08-27 20:33 -------
Actual, I have the feeling the attr.proc_pointer is not saved at all in
module.c, cf. ab_attribute in that file. One should check whether other
attributes are also missing.
Dominique: Thanks for finding it; may this helps also with PR 37254.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37253
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/37253] Segmentation fault with procedure pointer
2008-08-27 10:51 [Bug fortran/37253] New: Segmentation fault with procedure pointer dominiq at lps dot ens dot fr
` (2 preceding siblings ...)
2008-08-27 20:34 ` burnus at gcc dot gnu dot org
@ 2008-08-27 21:12 ` janus at gcc dot gnu dot org
2008-08-28 11:25 ` janus at gcc dot gnu dot org
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: janus at gcc dot gnu dot org @ 2008-08-27 21:12 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from janus at gcc dot gnu dot org 2008-08-27 21:10 -------
> Actual, I have the feeling the attr.proc_pointer is not saved at all in
> module.c, cf. ab_attribute in that file.
Exactly. Thanks for pointing this out. The following patch fixes it:
Index: gcc/fortran/module.c
===================================================================
--- gcc/fortran/module.c (revision 139622)
+++ gcc/fortran/module.c (working copy)
@@ -1643,7 +1643,7 @@ mio_internal_string (char *string)
typedef enum
{ AB_ALLOCATABLE, AB_DIMENSION, AB_EXTERNAL, AB_INTRINSIC, AB_OPTIONAL,
- AB_POINTER, AB_TARGET, AB_DUMMY, AB_RESULT, AB_DATA,
+ AB_POINTER, AB_PROC_POINTER, AB_TARGET, AB_DUMMY, AB_RESULT, AB_DATA,
AB_IN_NAMELIST, AB_IN_COMMON, AB_FUNCTION, AB_SUBROUTINE, AB_SEQUENCE,
AB_ELEMENTAL, AB_PURE, AB_RECURSIVE, AB_GENERIC, AB_ALWAYS_EXPLICIT,
AB_CRAY_POINTER, AB_CRAY_POINTEE, AB_THREADPRIVATE, AB_ALLOC_COMP,
@@ -1661,6 +1661,7 @@ static const mstring attr_bits[] =
minit ("INTRINSIC", AB_INTRINSIC),
minit ("OPTIONAL", AB_OPTIONAL),
minit ("POINTER", AB_POINTER),
+ minit ("PROC_POINTER", AB_PROC_POINTER),
minit ("VOLATILE", AB_VOLATILE),
minit ("TARGET", AB_TARGET),
minit ("THREADPRIVATE", AB_THREADPRIVATE),
@@ -1743,6 +1744,8 @@ mio_symbol_attribute (symbol_attribute *
MIO_NAME (ab_attribute) (AB_OPTIONAL, attr_bits);
if (attr->pointer)
MIO_NAME (ab_attribute) (AB_POINTER, attr_bits);
+ if (attr->proc_pointer)
+ MIO_NAME (ab_attribute) (AB_PROC_POINTER, attr_bits);
if (attr->is_protected)
MIO_NAME (ab_attribute) (AB_PROTECTED, attr_bits);
if (attr->value)
@@ -1839,6 +1842,9 @@ mio_symbol_attribute (symbol_attribute *
case AB_POINTER:
attr->pointer = 1;
break;
+ case AB_PROC_POINTER:
+ attr->proc_pointer = 1;
+ break;
case AB_PROTECTED:
attr->is_protected = 1;
break;
--
janus at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|unassigned at gcc dot gnu |janus at gcc dot gnu dot org
|dot org |
Status|NEW |ASSIGNED
Last reconfirmed|2008-08-27 12:35:40 |2008-08-27 21:10:58
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37253
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/37253] Segmentation fault with procedure pointer
2008-08-27 10:51 [Bug fortran/37253] New: Segmentation fault with procedure pointer dominiq at lps dot ens dot fr
` (3 preceding siblings ...)
2008-08-27 21:12 ` janus at gcc dot gnu dot org
@ 2008-08-28 11:25 ` janus at gcc dot gnu dot org
2008-08-28 15:13 ` janus at gcc dot gnu dot org
2008-08-28 15:14 ` janus at gcc dot gnu dot org
6 siblings, 0 replies; 8+ messages in thread
From: janus at gcc dot gnu dot org @ 2008-08-28 11:25 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from janus at gcc dot gnu dot org 2008-08-28 11:24 -------
> One should check whether other attributes are also missing.
attr.procedure is missing as well. I'll provide an extended patch.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37253
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/37253] Segmentation fault with procedure pointer
2008-08-27 10:51 [Bug fortran/37253] New: Segmentation fault with procedure pointer dominiq at lps dot ens dot fr
` (4 preceding siblings ...)
2008-08-28 11:25 ` janus at gcc dot gnu dot org
@ 2008-08-28 15:13 ` janus at gcc dot gnu dot org
2008-08-28 15:14 ` janus at gcc dot gnu dot org
6 siblings, 0 replies; 8+ messages in thread
From: janus at gcc dot gnu dot org @ 2008-08-28 15:13 UTC (permalink / raw)
To: gcc-bugs
------- Comment #5 from janus at gcc dot gnu dot org 2008-08-28 15:12 -------
Subject: Bug 37253
Author: janus
Date: Thu Aug 28 15:10:50 2008
New Revision: 139713
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=139713
Log:
2008-08-28 Janus Weil <janus@gcc.gnu.org>
PR fortran/37253
* module.c (ab_attribute,attr_bits,mio_symbol_attribute): Take care of
saving attr.procedure and attr.proc_ptr to the module file.
2008-08-28 Janus Weil <janus@gcc.gnu.org>
PR fortran/37253
* gfortran.dg/proc_ptr_10.f90: New.
Added:
trunk/gcc/testsuite/gfortran.dg/proc_ptr_10.f90
Modified:
trunk/gcc/fortran/ChangeLog
trunk/gcc/fortran/module.c
trunk/gcc/testsuite/ChangeLog
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37253
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/37253] Segmentation fault with procedure pointer
2008-08-27 10:51 [Bug fortran/37253] New: Segmentation fault with procedure pointer dominiq at lps dot ens dot fr
` (5 preceding siblings ...)
2008-08-28 15:13 ` janus at gcc dot gnu dot org
@ 2008-08-28 15:14 ` janus at gcc dot gnu dot org
6 siblings, 0 replies; 8+ messages in thread
From: janus at gcc dot gnu dot org @ 2008-08-28 15:14 UTC (permalink / raw)
To: gcc-bugs
------- Comment #6 from janus at gcc dot gnu dot org 2008-08-28 15:13 -------
Fixed in r139713. Closing.
--
janus at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution| |FIXED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37253
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2008-08-28 15:14 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-08-27 10:51 [Bug fortran/37253] New: Segmentation fault with procedure pointer dominiq at lps dot ens dot fr
2008-08-27 12:37 ` [Bug fortran/37253] " janus at gcc dot gnu dot org
2008-08-27 20:31 ` burnus at gcc dot gnu dot org
2008-08-27 20:34 ` burnus at gcc dot gnu dot org
2008-08-27 21:12 ` janus at gcc dot gnu dot org
2008-08-28 11:25 ` janus at gcc dot gnu dot org
2008-08-28 15:13 ` janus at gcc dot gnu dot org
2008-08-28 15:14 ` janus at gcc dot gnu dot 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).