- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am puzzled why this program compiles program ntest interface subroutine itakepointer(p) integer, dimension(:), pointer :: p => null() end subroutine itakepointer end interface end program ntest I do ifort -stand f95 -warn all ntest.f90 If I explicitly add `save' it fails program ntest interface subroutine itakepointer(p) integer, dimension(:), pointer, save :: p => null() end subroutine itakepointer end interface end program ntest ntest.f90(4): error #6453: The SAVE attribute conflicts with other declarations.
integer, dimension(:), pointer, save :: p => null() -----------------------------------------------^ compilation aborted for ntest.f90 (code 1) For me it seems the following part of the standard implies that those two programs should be equivalent and not confirming. http://j3-fortran.org/doc/standing/archive/007/97-007r2/ascii/c05.txt If initialization is =>NULL (), object-name shall be a pointer, and its initial association status is disassociated. Use of =>NULL () in a scoping unit is a reference to the intrinsic function NULL. 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, or by inclusion of the object-name in a SAVE statement (5.2.4). ifort version 13.1.1 Linux 2.6.37.6-24-desktop #1 SMP PREEMPT 2012-10-18 22:36:08 +0200 x86_64 x86_64 x86_64 GNU/Linux
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Neither of these are standard-conforming as they violate this constraint from F2008:
C506 (R503) An initialization shall not appear if object-name is a dummy argument, a function result, an object in a named common block unless the type declaration is in a block data program unit, an object in blank common, an allocatable variable, or an automatic object.
In the second case, the compiler notices you are trying to SAVE a dummy argument, which is not allowed. But it should also reject the initialization. I will report this to the developers.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am puzzled why this program compiles
program ntest
interface
subroutine itakepointer(p)
integer, dimension(:), pointer :: p => null()
end subroutine itakepointer
end interface
end program ntest
I do
ifort -stand f95 -warn all ntest.f90
If I explicitly add `save' it fails
program ntest
interface
subroutine itakepointer(p)
integer, dimension(:), pointer, save :: p => null()
end subroutine itakepointer
end interface
end program ntest
ntest.f90(4): error #6453: The SAVE attribute conflicts with other declarations.
integer, dimension(:), pointer, save :: p => null()
-----------------------------------------------^
compilation aborted for ntest.f90 (code 1)
For me it seems the following part of the standard implies that those
two programs should be equivalent and not confirming.
http://j3-fortran.org/doc/standing/archive/007/97-007r2/ascii/c05.txt
If initialization is =>NULL (), object-name shall be a pointer, and
its initial association status is disassociated. Use of =>NULL () in
a scoping unit is a reference to the intrinsic function NULL.
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, or by inclusion of the object-name in a SAVE
statement (5.2.4).
ifort version 13.1.1
Linux 2.6.37.6-24-desktop #1 SMP PREEMPT 2012-10-18 22:36:08 +0200 x86_64 x86_64 x86_64 GNU/Linux
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Neither of these are standard-conforming as they violate this constraint from F2008:
C506 (R503) An initialization shall not appear if object-name is a dummy argument, a function result, an object in a named common block unless the type declaration is in a block data program unit, an object in blank common, an allocatable variable, or an automatic object.
In the second case, the compiler notices you are trying to SAVE a dummy argument, which is not allowed. But it should also reject the initialization. I will report this to the developers.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'd argue that your first program (without save) should also fail to compile because p is a dummy argument.
According to Metcalf, Reid, and Cohen, Fortran 95/2003 explained (7.5.3), a pointer that is initialised in its declaration must not be a dummy argument or function result.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I think Steve is agreeing with you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I think Mark and I were posting at the same time. Both of us agree that the programs are incorrect and that the compiler should reject both.

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page