- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Is the following simple code snippet standard-conforming? The code compiles with no errors or warnings with the latest Intel Fortran 16.0 compiler, update 1. Note the missing proc_language_binding_spec of bind(C) on the procedure target which, to me, appears like a difference in characteristics of the object and the target. Is this something a coder can expect from the compiler to get flagged as an error?
Thanks,
module m implicit none abstract interface subroutine Ifoo() bind(C) end subroutine Ifoo end interface procedure(Ifoo), pointer :: foo => subfoo contains subroutine subfoo() !.. Note the missing proc_language_binding_spec of bind(C) end subroutine subfoo end module m
Listed below is an extract from Fortran 2008 standard document (WD 1539-1 J3/10-007r1 dated 2010-11-24):
7.2.2.4 Procedure pointer assignment .. 3 If the pointer object has an explicit interface, its characteristics shall be the same as the pointer target except that the pointer target may be pure even if the pointer object is not pure and the pointer target may be an elemental intrinsic procedure even if the pointer object is not elemental.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
One of the "characteristics of procedures" is "whether it has the BIND attribute" (12.3.1), so no, this code is nonconforming. The standard doesn't require a compiler to diagnose it, but a good one should.
However,I'd sure like to know which ifort you managed to get this to compile with, as we don't yet support pointer initialization to anything but NULL():
U607837.f90(13): error #6592: This symbol must be a defined parameter, an enumer ator, or an argument of an inquiry function that evaluates to a compile-time con stant. [SUBFOO] procedure(Ifoo), pointer :: foo => subfoo --------------------------------------^ U607837.f90(13): error #6973: This is not a valid initialization expression. [ SUBFOO] procedure(Ifoo), pointer :: foo => subfoo --------------------------------------^
When I compile this with an internal copy of our next major release, it complains:
U607837.f90(13): error #8178: The procedure pointer and the procedure target mus t have matching arguments. procedure(Ifoo), pointer :: foo => subfoo -------------------------------^
Not the best error message (I will let the developers know about this), but an error nonetheless. I get the same error if I use pointer assignment in 16.0. But I poked more at this and see that even if I do add the BIND(C) to subfoo I still get this error, so something else is wrong.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Ah, turns out this is more interesting... The error message above is unrelated to the BIND mismatch and happens when the procedure has no arguments. This was previously reported as DPD200378606. When I modified the source to account for that, ifort indeed doesn't detect the mismatch in BIND, so I escalated that as DPD200381358.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Steve Lionel (Intel) wrote:
.. However,I'd sure like to know which ifort you managed to get this to compile with, as we don't yet support pointer initialization to anything but NULL(): .. .. But I poked more at this and see that even if I do add the BIND(C) to subfoo I still get this error, so something else is wrong.
Steve,
Thanks much for reviewing this. Sorry I got a bit confused in keeping code and the compiler version consistent while being eager to put together a small reproducer. For Intel compiler, the snippet should be as follows, a variant of the one in the original post:
module m use, intrinsic :: iso_c_binding, only : c_int implicit none abstract interface subroutine Ifoo( i ) bind(C) import :: c_int integer(c_int), value :: i end subroutine Ifoo end interface procedure(Ifoo), pointer :: foo contains subroutine subfoo( i ) bind(C) integer(c_int), value :: i end subroutine subfoo subroutine bar() foo => subfoo end subroutine bar end module m
Compiling with Intel(R) Visual Fortran Compiler 16.0.1.146 [Intel(R) 64]... m.f90 m - 0 error(s), 0 warning(s)
Strange things is if the dummy argument i is removed, then the compiler gives error #8178. So as you indicated, something is not quite right. Perhaps you can discuss with developers and make sense out of the several scenarios.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes, see my later reply. I constructed an example just like your later one and saw the issues.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This has been fixed for a major release later this year.
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page