public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/38802] New: Seg fault for RESULT with allocatable components
@ 2009-01-11 12:15 pault at gcc dot gnu dot org
2009-01-11 13:26 ` [Bug fortran/38802] " dominiq at lps dot ens dot fr
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: pault at gcc dot gnu dot org @ 2009-01-11 12:15 UTC (permalink / raw)
To: gcc-bugs
Posted on the list by Marco Restelli http://gcc.gnu.org/ml/fortran/2009-01/
$ gfortran test.f90 -o test
$ ./test
Segmentation fault
$ gfortran --version
GNU Fortran (GCC) 4.4.0 20090110 (experimental) [trunk revision 143243]
System:
Linux 2.6.23-gentoo-r6 x86_64 AMD Turion(tm) 64 Mobile Technology
ML-32 AuthenticAMD GNU/Linux
module mod_a
implicit none
public :: a_fun, t_1, t_2
private
type t_1
real :: coeff
end type t_1
type t_2
type(t_1), allocatable :: mons(:)
end type t_2
contains
function a_fun(r) result(p)
integer, intent(in) :: r
type(t_2) :: p(r+1)
! Using an allocatable works
!type(t_2), allocatable :: p(:)
! allocate(p(r+1))
write(*,*) 'shape(p) is ', shape(p)
end function a_fun
end module mod_a
A workaround is to not use the RESULT variable. The code shows that the result
is being nullified before its upper bound is established.
Paul
program test
use mod_a, only: a_fun, t_1, t_2
implicit none
type(t_2) x(1)
x = a_fun(0)
end program test
--
Summary: Seg fault for RESULT with allocatable components
Product: gcc
Version: 4.4.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: pault at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38802
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug fortran/38802] Seg fault for RESULT with allocatable components
2009-01-11 12:15 [Bug fortran/38802] New: Seg fault for RESULT with allocatable components pault at gcc dot gnu dot org
@ 2009-01-11 13:26 ` dominiq at lps dot ens dot fr
2009-01-12 6:21 ` pault at gcc dot gnu dot org
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: dominiq at lps dot ens dot fr @ 2009-01-11 13:26 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from dominiq at lps dot ens dot fr 2009-01-11 13:26 -------
Confirmed on i686-apple-darwin9 with -m64 or -m32 with optimization -O1 and
above:
Thread 0 Crashed:
0 a.out 0x00001dec __mod_a_MOD_a_fun + 30
1 a.out 0x00001daf MAIN__ + 141
2 a.out 0x00001f98 main + 40
3 a.out 0x00001cf6 start + 54
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38802
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug fortran/38802] Seg fault for RESULT with allocatable components
2009-01-11 12:15 [Bug fortran/38802] New: Seg fault for RESULT with allocatable components pault at gcc dot gnu dot org
2009-01-11 13:26 ` [Bug fortran/38802] " dominiq at lps dot ens dot fr
@ 2009-01-12 6:21 ` pault at gcc dot gnu dot org
2009-04-08 17:28 ` burnus at gcc dot gnu dot org
2009-04-19 15:03 ` pault at gcc dot gnu dot org
3 siblings, 0 replies; 5+ messages in thread
From: pault at gcc dot gnu dot org @ 2009-01-12 6:21 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from pault at gcc dot gnu dot org 2009-01-12 06:21 -------
This does the job:
Index: gcc/fortran/trans-array.c
===================================================================
--- gcc/fortran/trans-array.c (revision 143242)
+++ gcc/fortran/trans-array.c (working copy)
@@ -5733,7 +5733,7 @@
}
/* Dummy and use associated variables don't need anything special. */
- if (sym->attr.dummy || sym->attr.use_assoc)
+ if (sym->attr.dummy || sym->attr.use_assoc || sym->attr.result)
{
gfc_add_expr_to_block (&fnblock, body);
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 |
Status|UNCONFIRMED |ASSIGNED
Ever Confirmed|0 |1
Last reconfirmed|0000-00-00 00:00:00 |2009-01-12 06:21:46
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38802
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug fortran/38802] Seg fault for RESULT with allocatable components
2009-01-11 12:15 [Bug fortran/38802] New: Seg fault for RESULT with allocatable components pault at gcc dot gnu dot org
2009-01-11 13:26 ` [Bug fortran/38802] " dominiq at lps dot ens dot fr
2009-01-12 6:21 ` pault at gcc dot gnu dot org
@ 2009-04-08 17:28 ` burnus at gcc dot gnu dot org
2009-04-19 15:03 ` pault at gcc dot gnu dot org
3 siblings, 0 replies; 5+ messages in thread
From: burnus at gcc dot gnu dot org @ 2009-04-08 17:28 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from burnus at gcc dot gnu dot org 2009-04-08 17:28 -------
Commit log went to the wrong PR:
Author: pault
Date: Wed Apr 8 08:59:34 2009
New Revision: 145714
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=145714
Log:
2009-04-08 Paul Thomas <pault@gcc.gnu.org>
PR fortran/38863
* trans-array.c (gfc_trans_deferred_array): Return if this
is a result variable.
2009-04-08 Paul Thomas <pault@gcc.gnu.org>
PR fortran/38863
* gfortran.dg/alloc_comp_result_1.f90: New test.
Added:
trunk/gcc/testsuite/gfortran.dg/alloc_comp_result_1.f90
Modified:
trunk/gcc/fortran/ChangeLog
trunk/gcc/fortran/trans-array.c
trunk/gcc/testsuite/ChangeLog
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38802
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug fortran/38802] Seg fault for RESULT with allocatable components
2009-01-11 12:15 [Bug fortran/38802] New: Seg fault for RESULT with allocatable components pault at gcc dot gnu dot org
` (2 preceding siblings ...)
2009-04-08 17:28 ` burnus at gcc dot gnu dot org
@ 2009-04-19 15:03 ` pault at gcc dot gnu dot org
3 siblings, 0 replies; 5+ messages in thread
From: pault at gcc dot gnu dot org @ 2009-04-19 15:03 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from pault at gcc dot gnu dot org 2009-04-19 15:03 -------
Fixed on trunk.
Thanks for the report
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=38802
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2009-04-19 15:03 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-01-11 12:15 [Bug fortran/38802] New: Seg fault for RESULT with allocatable components pault at gcc dot gnu dot org
2009-01-11 13:26 ` [Bug fortran/38802] " dominiq at lps dot ens dot fr
2009-01-12 6:21 ` pault at gcc dot gnu dot org
2009-04-08 17:28 ` burnus at gcc dot gnu dot org
2009-04-19 15:03 ` pault 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).