Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Questions about Fortran 2003 "volatile"

36 views
Skip to first unread message

Steven Correll

unread,
Jan 17, 2007, 5:32:38 PM1/17/07
to
1. Should a compiler report violations of constraints C1232 and C1233
in these examples?

> cat s8.f90
subroutine s8()
implicit none
interface
subroutine sub8(dummy8)
integer, volatile, dimension(3) :: dummy8
end subroutine sub8
end interface
integer, dimension(8) :: a
call sub8(a(1:5:2))
end subroutine s8
> gfortran s8.f90 -c -std=f2003
> cat s9.f90
subroutine s9(s9dummy)
implicit none
integer, dimension(:) :: s9dummy
interface
subroutine sub9(dummy9)
integer, volatile, dimension(3) :: dummy9
end subroutine sub9
end interface
integer, dimension(9) :: a
call sub9(s9dummy)
end subroutine s9
> gfortran s9.f90 -c -std=f2003
> cat s10.f90
subroutine s10()
implicit none
interface
subroutine sub10(dummy10)
integer, volatile, dimension(10) :: dummy10
end subroutine sub10
end interface
integer, dimension(:), pointer :: a
call sub10(a)
end subroutine s10
> gfortran s10.f90 -c -std=f2003
>

2. Does the standard forbid the use of the "volatile" attribute with a
function result variable (and, if so, where in the document is the
prohibition)?

> cat fcn.f90
function f() result(fr)
integer, volatile :: fr
fr = 5
end function f
> gfortran fcn.f90 -c -std=f2003
> ifort fcn.f90
fortcom: Error: fcn.f90, line 1: Conflicting attributes for RESULT
name [FR]
function f() result(fr)
--------------------^
compilation aborted for fcn.f90 (code 1)

3. In section 11.2.1, the standard seems to say that one can add the
"volatile" attribute to the local instance of an entity accessed via
host association. Is the following code legal?

> cat mod13.f90
module mod13
implicit none
integer :: v13
end module mod13
> cat mod13a.f90
module mod13a
use mod13
implicit none
volatile :: v13
end module mod13a
> cat s14.f90
subroutine s14()
use mod13
implicit none
volatile :: v13
end subroutine s14
> gfortran mod13.f90 mod13a.f90 -c -std=f2003
mod13a.f90:4.16:

volatile :: v13
1
Error: Cannot change attributes of USE-associated symbol v13 at (1)
> gfortran mod13.f90 s14.f90 -c -std=f2003
s14.f90:4.17:

volatile :: v13
1
Error: Cannot change attributes of USE-associated symbol v13 at (1)
>

> ifort mod13.f90 s14.f90 -c
fortcom: Error: s14.f90, line 4: Conflicting attributes or multiple
declaration of name. [V13]
volatile :: v13
--------------^
compilation aborted for s14.f90 (code 1)
> ifort mod13.f90 mod13a.f90
fortcom: Error: mod13a.f90, line 4: Conflicting attributes or
multiple declaration of name. [V13]
volatile :: v13
-------------^
compilation aborted for mod13a.f90 (code 1)

Thanks in advance.

Michael Metcalf

unread,
Jan 19, 2007, 7:51:32 AM1/19/07
to

"Steven Correll" <steven....@gmail.com> wrote in message
news:1169073158.6...@q2g2000cwa.googlegroups.com...

From John Reid:

>> 1. Should a compiler report violations of constraints C1232 and C1233
>> in these examples?

Yes, for a F2003 compiler in strict conformance mode. But no compiler yet
claims
to fully conform to F2003.

> >
>>
>> 2. Does the standard forbid the use of the "volatile" attribute with a
>> function result variable (and, if so, where in the document is the
>> prohibition)?

No, IMHO.


>>
>> 3. In section 11.2.1, the standard seems to say that one can add the
>> "volatile" attribute to the local instance of an entity accessed via
>> host association. Is the following code legal?

Yes, IMHO, see the second paragraph of 11.2.1.

John.


Steve Lionel

unread,
Jan 19, 2007, 1:59:58 PM1/19/07
to
Steven Correll wrote:
> 1. Should a compiler report violations of constraints C1232 and C1233
> in these examples?

> 2. Does the standard forbid the use of the "volatile" attribute with a


> function result variable (and, if so, where in the document is the
> prohibition)?

> 3. In section 11.2.1, the standard seems to say that one can add the


> "volatile" attribute to the local instance of an entity accessed via
> host association. Is the following code legal?

I have entered bug reports for these issues against ifort.


Steve Lionel
Developer Products Division
Intel Corporation
Nashua, NH

User communities for Intel Software Development Products
http://softwareforums.intel.com/
Intel Fortran Support
http://developer.intel.com/software/products/support/
My Fortran blog
http://www.intel.com/software/drfortran

Tobias Burnus

unread,
Jan 20, 2007, 8:53:51 PM1/20/07
to
Hi Steven,

Steven Correll wrote:
> 1. Should a compiler report violations of constraints C1232 and C1233
> in these examples?

> 3. In section 11.2.1, the standard seems to say that one can add the
> "volatile" attribute to the local instance of an entity accessed via
> host association. Is the following code legal?

Thanks for finding these bugs - all compiler vendors are glad to have
such alert customers which find bugs for them. Thus thanks from the
gfortran team.

Regarding gfortran, these problems are now tracked as PR30520. As a
patch is has been posted and thus gfortran will get fixed in the next
few days. (There are some special cases, which are not that easily
fixable, however, and which are tracked in PR30522.)

(For gfortran it is better to fill problem reports in bugzilla or send
them to the gfortran mailing list [at least when it is clear that the
compiler has a bug or missing diagnostics] as otherwise the reports
might be missed.)

Tobias

Steven Correll

unread,
Jan 26, 2007, 12:09:50 AM1/26/07
to
Thanks to all those who replied. When more than one compiler disagrees
with my reading of the standard, I tend to doubt myself, so I
appreciate the confirmation.--Steve

0 new messages