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: "François-Xavier Coudert" <fxcoudert at gmail dot com>
- To: "Daniel Franke" <franke dot daniel at gmail dot com>
- Cc: fortran at gcc dot gnu dot org
- Date: Tue, 21 Nov 2006 08:31:03 +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:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=tQzmQ2IC/EFGipSRw9H4eeOmmwgXcqtdVym1jxPQXeVHo2nBz7yhYXTs6vF9PShycfZ2geuwdoVAInj3LXPg5LdIALJGNacH0lxTznSqG3TEfqOycXH+Gr4pVvcetJWj91xK3gRxEOTGlQnhlBZRbOYbAtwTxvjc8mjM/dzCKVA=
- References: <200611210127.26748.franke.daniel@gmail.com>
$> cat sigsev.f90
PROGRAM main
TYPE :: atype
INTEGER, POINTER :: p => null()
END TYPE
TYPE(atype), DIMENSION(:), POINTER :: t
t => null()
WRITE(*,*) func(t)
CONTAINS
ELEMENTAL LOGICAL FUNCTION func(t)
TYPE(atype), INTENT(in) :: t
func = ASSOCIATED(t%p)
END FUNCTION
END PROGRAM
As output, I would expect an empty line (as func should not be called?)
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.
The Sun compiler also generates an executable that segfaults at
runtime. With checking enabled, the Intel compiler says:
forrtl: severe (408): fort: (7): Attempt to use pointer T when it is
not associated with a target
Regards,
FX