Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
28864 Discussions

Can the dummy argument of a PURE subroutine with INTENT(OUT) attribute be unlimited polymorphic?

FortranFan
Honored Contributor III
1,862 Views

The following code compiles with no errors or warnings with the latest Intel Fortran compiler 2015, update 2 even with -stand compiler option:

   pure subroutine foo(val)

      class(*), allocatable, intent(out) :: val

      allocate(val, source=0.0)

   end subroutine foo

but gfortran (GCC 5 development truck) throws an error:

    pure subroutine foo(val)
                          1
Error: INTENT(OUT) argument 'val' of pure procedure 'foo' at (1) may not be polymorphic

 

I fail to see anything in the standard about INTENT(OUT) and polymorphic dummy arguments and pure procedures.  Is gfortran misinterpreting the standard or is Intel Fortran incorrect to allow this?

Thanks,

 

0 Kudos
10 Replies
IanH
Honored Contributor III
1,862 Views

This is a consequence of a change made with F2008 corrigendum one^H^H^Htwo.  The issue is that the compiler does not know at compile time whether a polymorphic object has a finalizer or the nature of such a finalizer, there is no requirement that a finalizer be pure, and hence you have the possibility with an INTENT(OUT) polymorphic argument that the pure procedure will have impure thoughts without the compiler being able to detect such thoughts.

0 Kudos
FortranFan
Honored Contributor III
1,862 Views

I overlooked the corrigendum, thanks for pointing it out!  Is there a revised Fortran 2008 standards document that has been reconciled with the 3 corrigenda and contains the replaced (corrected) wordings?

 

0 Kudos
Steven_L_Intel1
Employee
1,862 Views

http://j3-fortran.org/doc/year/14/14-007r2.pdf has been updated through Corrigendum 2. There isn't one with Corrigendum 3. You could also reference http://j3-fortran.org/doc/year/15/15-007.pdf which is the current F2015 draft, but this might mislead you about F2008 changes.

0 Kudos
FortranFan
Honored Contributor III
1,862 Views

Steve,

Thanks for the links.

Is this on the list for Intel compiler updates?  i.e., will a future release give a warning/error in such situations, especially if -stand option is in effect?

0 Kudos
FortranFan
Honored Contributor III
1,862 Views

Steve Lionel (Intel) wrote:

..reference http://j3-fortran.org/doc/year/15/15-007.pdf which is the current F2015 draft, ..

Oh, I was looking for this - thanks for pointing it out.  By the way, it isn't possible to quickly figure out how Fortran 2015 (as of this draft) is different from Fortran 2008, is there?  I wish there were a section in these documents, perhaps as an annex (informative) toward the end, that would summarize what is new and what has changed since the final version of the previous standard. 

0 Kudos
Steven_L_Intel1
Employee
1,862 Views

The Introduction has a list of what has changed.

The issue in this thread comes from interpretation F08/0033 which was indeed in Corrigendum 1, not 2. We do implement all the corrigendum changes over time. I will make sure this is on our list.

0 Kudos
Fran-Martinez
Beginner
1,830 Views

Do you kno if this has already been implemented in version 19.1? It does not seem to be the case but maybe I am using the wrong compiler options (/stand:f18 ?)

0 Kudos
Steve_Lionel
Honored Contributor III
1,819 Views

It is not implemented in the oneAPI compiler, and isn't in 19.1 either. I no longer have access to the bug report database to be able to tell whether the developers have been alerted to this issue. I would hope that all of the F2008 corrigendum issues would have been noted.

0 Kudos
Barbara_P_Intel
Employee
1,783 Views

I filed a bug report on this, CMPLRIL0-33535. I'll let you know when it's fixed.



0 Kudos
Barbara_P_Intel
Employee
1,608 Views

Sorry for the late notice on this... it's fixed in theh 2021.3.0 compiler.



0 Kudos
Reply