From owner-sc22wg5@open-std.org  Sat Feb 13 00:18:14 2010
Return-Path: <owner-sc22wg5@open-std.org>
X-Original-To: sc22wg5-dom8
Delivered-To: sc22wg5-dom8@www2.open-std.org
Received: by www2.open-std.org (Postfix, from userid 521)
	id 2B0B4C3BA34; Sat, 13 Feb 2010 00:18:14 +0100 (CET)
X-Original-To: sc22wg5@open-std.org
Delivered-To: sc22wg5@open-std.org
Received: from mail1.cray.com (mail1.cray.com [136.162.62.100])
	by www2.open-std.org (Postfix) with ESMTP id 6A340C3BA25
	for <sc22wg5@open-std.org>; Sat, 13 Feb 2010 00:18:12 +0100 (CET)
Received: from beaver.us.cray.com (beaver.us.cray.com [172.30.74.51])
	by mail1.cray.com (8.13.6/8.13.3/gw-5323) with ESMTP id o1CNI6at023472
	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL);
	Fri, 12 Feb 2010 17:18:06 -0600 (CST)
Received: from cfexcas01.americas.cray.com (cfexcas01-2.us.cray.com [172.30.74.227])
	by beaver.us.cray.com (8.13.8/8.13.3/hub-5273) with ESMTP id o1CNI5dw025542;
	Fri, 12 Feb 2010 17:18:05 -0600
Received: from fortran.us.cray.com (172.31.19.200) by
 cfexcas01.americas.cray.com (172.30.74.226) with Microsoft SMTP Server (TLS)
 id 8.1.393.1; Fri, 12 Feb 2010 17:18:04 -0600
Message-ID: <4B75E1B3.5000608@cray.com>
Date: Fri, 12 Feb 2010 17:18:11 -0600
From: Bill Long <longb@cray.com>
Reply-To: <longb@cray.com>
Organization: Cray Inc.
User-Agent: Thunderbird 2.0.0.23 (Macintosh/20090812)
MIME-Version: 1.0
To: fortran standards email list for J3 <j3@j3-fortran.org>
Cc: "N.M. Maclaren" <nmm1@cam.ac.uk>, sc22wg5 <sc22wg5@open-std.org>
Subject: Re: (j3.2006) (SC22WG5.4166) Please say this isn't allowed!
References: <20100206000326.EB642C3BA22@www2.open-std.org>	<20100207193242.EDEE6C3BA07@www2.open-std.org> <20100207205352.74732C3BA29@www2.open-std.org>
In-Reply-To: <20100207205352.74732C3BA29@www2.open-std.org>
Content-Type: text/plain; charset="ISO-8859-1"; format=flowed
Content-Transfer-Encoding: 7bit
X-Cray-VirusStatus: clean
Sender: owner-sc22wg5@open-std.org
Precedence: bulk



Reinhold Bader wrote:
> Hello,
> 
> referring to the 2003 standard, I think this is illegal due to 12.4.1.2 
> (p270,  20-22).:
> "If the dummy argument has the TARGET attribute and the corresponding 
> actual argument does not
> have the TARGET attribute or is an array section with a vector 
> subscript, any pointers associated with
> the dummy argument become undefined when execution of the procedure 
> completes."
> 
> Regards
> Reinhold
> 
> N.M. Maclaren schrieb:
>> While writing a paper on C interoperability, I was checking on Fortran's
>> equivalents to some C facilities, and I cannot find anything that forbids
>> this.  NAG objects to it, but Intel and Pathscale allow it - or, at 
>> least,
>> let it happen ....
>>

As noted in the citation from Reinhold above, the code is non-conforming 
because of the

     PRINT *, p

statement, as a pointer with an undefined association status cannot be a 
list item in an I/O statement.  However, this is not one of the 
transgressions that the compiler is required to detect, so the 
implementation is free to do anything it wants.  One version of 
"anything" for this case would be to leave the association status of p 
unchanged at the end of Fred, resulting in

 > ./a.out
  1.,  2.,  3.

All of Cray, PGI, Pathscale, Intel, and gfortran produce this output 
(with varying amount of spacing and trailing zero characters).

Cheers,
Bill


>> PROGRAM Main
>>    REAL, POINTER, DIMENSION(:) :: p => NULL()
>>    REAL :: x = 1.0, y = 2.0, z = 3.0
>>    CALL Fred ( (/ x,y,z /) )
>>    PRINT *, p
>> CONTAINS
>>    SUBROUTINE Fred (arg)
>>        REAL, TARGET, DIMENSION(:) :: arg
>>        p => arg
>>    END SUBROUTINE Fred
>> END PROGRAM Main
>>
>> Regards,
>> Nick Maclaren.
>>
> 
> _______________________________________________
> J3 mailing list
> J3@j3-fortran.org
> http://j3-fortran.org/mailman/listinfo/j3

-- 
Bill Long                                           longb@cray.com
Fortran Technical Support    &                 voice: 651-605-9024
Bioinformatics Software Development            fax:   651-605-9142
Cray Inc./Cray Plaza, Suite 210/380 Jackson St./St. Paul, MN 55101


