Aleksandar Donev wrote:
>> The NAG compiler is right, SAVE is required. I am not quite
>> sure where you get the idea that default initialization means no save.
I agree with the rest of the post, but isn't it the Lahey compiler
that's right and not NAG?
The save in
! type (xy), save :: a = xy(2)
doesn't have to be written because explicit initialization implies save,
without regard to whether xy has default initialization of not,
or whether it's in a module or not.
Here's what the standard says:
-----
Last paragraph of Sec. 5.1 of F2003 (and similarly of F95):
The presence of initialization implies that object-name is saved,
except for an object-name in a named common block or an object-name
with the PARAMETER attribute. The implied SAVE attribute may be
reaffirmed by explicit use of the SAVE attribute in the type
declaration statement, by inclusion of the object-name in a SAVE
statement (5.2.12), or by the appearance of a SAVE statement without
a saved-entity-list in the same scoping unit.
Last sentence of 3rd paragraph of 4.5.3.4 (middle of 5th paragraph of
4.4.1 for F95):
Unlike explicit initialization, default initialization does not imply
that the object has the SAVE attribute.
C1107 of F2003 (4th constraint after R1106 for F95):
If an object of a type for which component-initialization is
specified (R444) appears in the specification-part of a module and
does not have the ALLOCATABLE or POINTER attribute, the object shall
have the SAVE attribute.
-----
Taken together I think that means a default-initialized object in a
module needs to be given the SAVE attribute either implicitly by
(explicit, not default) initialization or explicitly by writing SAVE.
--
Yasuki Arasaki
[log in to unmask]
|