From owner-sc22wg5+sc22wg5-dom8=www.open-std.org@open-std.org  Fri Dec 16 14:05:11 2011
Return-Path: <owner-sc22wg5+sc22wg5-dom8=www.open-std.org@open-std.org>
X-Original-To: sc22wg5-dom8
Delivered-To: sc22wg5-dom8@www.open-std.org
Received: by www.open-std.org (Postfix, from userid 521)
	id 5302B35694B; Fri, 16 Dec 2011 14:05:11 +0100 (CET)
Delivered-To: sc22wg5@open-std.org
Received: from ppsw-52.csi.cam.ac.uk (ppsw-52.csi.cam.ac.uk [131.111.8.152])
	by www.open-std.org (Postfix) with ESMTP id 6919035660B
	for <sc22wg5@open-std.org>; Fri, 16 Dec 2011 14:05:08 +0100 (CET)
X-Cam-AntiVirus: no malware found
X-Cam-SpamDetails: not scanned
X-Cam-ScannerInfo: http://www.cam.ac.uk/cs/email/scanner/
Received: from hermes-2.csi.cam.ac.uk ([131.111.8.54]:51591)
	by ppsw-52.csi.cam.ac.uk (smtp.hermes.cam.ac.uk [131.111.8.159]:25)
	with esmtpa (EXTERNAL:nmm1) id 1RbXTI-0002ss-DA (Exim 4.72)
	(return-path <nmm1@hermes.cam.ac.uk>); Fri, 16 Dec 2011 13:05:08 +0000
Received: from prayer by hermes-2.csi.cam.ac.uk (hermes.cam.ac.uk)
	with local (PRAYER:nmm1) id 1RbXTI-0003Vh-1B (Exim 4.67)
	(return-path <nmm1@hermes.cam.ac.uk>); Fri, 16 Dec 2011 13:05:08 +0000
Received: from [131.111.10.32] by webmail.hermes.cam.ac.uk
	with HTTP (Prayer-1.3.4); 16 Dec 2011 13:05:08 +0000
Date: 16 Dec 2011 13:05:08 +0000
From: "N.M. Maclaren" <nmm1@cam.ac.uk>
To: sc22wg5@open-std.org
Subject: Is this obscure USE usage legal?
Message-ID: <Prayer.1.3.4.1112161305080.1672@hermes-2.csi.cam.ac.uk>
In-Reply-To: <20111120134657.46417356928@www.open-std.org>
References: <20111019141328.42FAD35690F@www.open-std.org>
 <20111120134657.46417356928@www.open-std.org>
X-Mailer: Prayer v1.3.4
Mime-Version: 1.0
Content-Type: text/plain; format=flowed; charset=ISO-8859-1
Sender: owner-sc22wg5@open-std.org
Precedence: bulk

This arose on the gfortran mailing list.  I am 90% sure that there is a bug
in both gfortran and Intel, especially as Sun, Pathscale and NAG all accept
this code.  But I am only 90% sure, as it all hangs on exactly which
scoping unit the word 'local' applies to WHILE processing recursive
inclusion!  Until this moment, it had never crossed my mind to query that.

Please tell me if I have missed something.

Regards,
Nick Maclaren.



module mod1
integer :: axx=2
end module mod1

module mod2
use mod1
end module mod2

subroutine sub1
use mod1, oxx=>axx
use mod2
implicit none
print*,axx   !line compiles OK for gfortran, fails for Intel
end subroutine sub1

subroutine sub2
use mod2
use mod1, oxx=>axx
implicit none
print*,axx  !line fails to compile for gfortran, OK for Intel
end subroutine sub2

