This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Re: SIGSEV in user-defined elemental function
- From: Daniel Franke <franke dot daniel at gmail dot com>
- To: "François-Xavier Coudert" <fxcoudert at gmail dot com>
- Cc: fortran at gcc dot gnu dot org
- Date: Tue, 21 Nov 2006 09:44:24 +0100
- Subject: Re: SIGSEV in user-defined elemental function
- Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:from:to:subject:date:user-agent:cc:references:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:message-id; b=jb5qnWK8X7EIY1qbfJ06LD6W4ApnQaSqw9XTeTYEisXuYM4b942xKW5mYXwe8t1oZdDWsb+HcaQtY5zE9qUU6YVrRtpgtyN3d31gkZLY1j2jNLLxXrjNJsoy7Y/mWVlm3MhGA9zQmcbdZstwjfmn5bLPT+ueTCKtzuhwO6M0zMI=
- References: <200611210127.26748.franke.daniel@gmail.com> <19c433eb0611202331j8db1a53m98ac37c1d5cda786@mail.gmail.com>
On Tuesday 21 November 2006 08:31, François-Xavier Coudert wrote:
FX,
> forrtl: severe (408): fort: (7): Attempt to use pointer T when it is
> not associated with a target
which version of ifort do you use? Here, with v9.0, I get:
$> ifort -g -warn all -check all main.f90 && ./a.out
[empty line]
$>
Which is, what I expected.
> I don't see why func wouldn't be called. And when it's called, then
> trying to use t%p when t is NULL is certainly the reason of your
> segfault.
I'm not sure how ELEMENTAL is implemented, but since the argument type of
func() is not a pointer type but a reference, one can not try to avoid this
segfault by
ELEMENTAL LOGICAL FUNCTION func(t)
TYPE(atype), INTENT(in) :: t
IF (ASSOCIATED(t))
func = ASSOCIATED(t%p)
ELSE
func = .FALSE.
END IF
END FUNCTION
or similar since both, gfortran and ifort, complain that 't' is lacking the
pointer attribute. Also, if func is put in a module, gdb shows a reference
for t, which is, from my point of view, questionable. I wouldn't argue if a
reference to null would be passed, but a random(?) address?
(gdb) run
Program received signal SIGSEGV, Segmentation fault.
0x0804859d in __themod__func (t=@0xf465f440) at sigsev.f90:31
31 func = ASSOCIATED(t%p)
Regards
Daniel
P.S. The modified code:
MODULE themod
TYPE :: atype
INTEGER, POINTER :: p => null()
END TYPE
CONTAINS
ELEMENTAL LOGICAL FUNCTION func(t)
TYPE(atype), INTENT(in) :: t
func = ASSOCIATED(t%p)
END FUNCTION
END MODULE
PROGRAM main
USE themod
TYPE(atype), DIMENSION(:), POINTER :: t
t => null()
WRITE(*,*) func(t)
END PROGRAM