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

NAME specifier of BIND attribute part of the characteristic of a procedure?

113 views
Skip to first unread message

Neil

unread,
Dec 3, 2018, 10:57:02 AM12/3/18
to
I'm working with a new compiler that regards the presence of the NAME= specifier in a procedure BIND attribute as a characteristic of the procedure in regards to the matching of actual and dummy arguments. So it rejects the following as invalid:

module example

abstract interface
subroutine foo() bind(c)
end subroutine
end interface

contains

subroutine my_foo() bind(c,name='')
end subroutine

subroutine pass_foo(proc)
procedure(foo) :: proc
end subroutine

subroutine with_my_foo
call pass_foo(my_foo) ! ERROR HERE
end subroutine

end module

My reading of 12.3.1 (F2008) is that only whether it has the BIND attribute is a characteristic of the procedure, and nothing about the specification of the binding label. So I think this compiler is incorrect here, but would like to see if anybody else agrees with me.

FortranFan

unread,
Dec 3, 2018, 11:25:35 AM12/3/18
to
On Monday, December 3, 2018 at 10:57:02 AM UTC-5, Neil wrote:

> I'm working with a new compiler that regards the presence of the NAME= specifier in a procedure BIND attribute as a characteristic of the procedure in regards to the matching of actual and dummy arguments. So it rejects the following as invalid:
>
> .. I think this compiler is incorrect here, but would like to see if anybody else agrees with me.


For whatever it's worth, my reading of the standard leads me to believe the same i.e., it's that compiler which is in error.

The code appears to conform to the standard; the implementation, my_foo, matches the abstract interface including in the BIND attribute characteristics and thus it's a valid actual argument to a procedure expecting a dummy argument with a procedure interface of foo.

Steve Lionel

unread,
Dec 3, 2018, 7:39:43 PM12/3/18
to
On 12/3/2018 11:25 AM, FortranFan wrote:
> For whatever it's worth, my reading of the standard leads me to believe the same i.e., it's that compiler which is in error.
>
> The code appears to conform to the standard; the implementation, my_foo, matches the abstract interface including in the BIND attribute characteristics and thus it's a valid actual argument to a procedure expecting a dummy argument with a procedure interface of foo.

The standard (F2018) says: "The characteristics of a procedure are the
classification of the procedure as a function or subroutine, whether it
is pure, whether it is elemental, whether it has the BIND attribute, the
characteristics of its dummy arguments, and the characteristics of its
function result if it is a function."

and

"If the interface of a dummy procedure is explicit, its characteristics
as a procedure (15.3.1) shall be the same as those of its effective
argument, except that a pure effective argument may be associated with a
dummy argument that is not pure and an elemental intrinsic actual
procedure may be associated with a dummy procedure (which cannot be
elemental)."

I see nothing in the posted code that violates this. I note that the
actual error message from the unnamed compiler was not shown - sometimes
the wording of the message isn't the same as the interpretation we were
given.

--
Steve Lionel
Retired Intel Fortran developer/support
Email: firstname at firstnamelastname dot com
Twitter: @DoctorFortran
LinkedIn: https://www.linkedin.com/in/stevelionel
Blog: http://intel.com/software/DrFortran

Neil

unread,
Dec 3, 2018, 11:24:12 PM12/3/18
to
On Monday, December 3, 2018 at 5:39:43 PM UTC-7, Steve Lionel wrote:
> [...] I note that the
> actual error message from the unnamed compiler was not shown - sometimes
> the wording of the message isn't the same as the interpretation we were
> given.

The error message was "Actual argument attributes do not match those specified by an accessible explicit interface", pointing to the indicated statement. Dropping the NAME= specifier makes the error go away, hence my interpretation.

Ron Shepard

unread,
Dec 4, 2018, 1:56:19 AM12/4/18
to
What exactly is the binding name of the procedure when the string is ''?
Is it the same as when the NAME= is not specified (i.e., the procedure
name in lower case)?

$.02 -Ron Shepard

Neil

unread,
Dec 4, 2018, 11:16:14 AM12/4/18
to
On Monday, December 3, 2018 at 11:56:19 PM UTC-7, Ron Shepard wrote:
> What exactly is the binding name of the procedure when the string is ''?
> Is it the same as when the NAME= is not specified (i.e., the procedure
> name in lower case)?

No, NAME="" means "no binding label" (15.5.2). In practice, I think there must be a binding label, but it is some compiler-specific mangled name that is unlikely to clash with anything. In the use case behind this example, the procedure is passed as a pointer to a C function to invoke, and is not called by name. So no binding label is needed. Since binding labels are global entities, it's best in this case to have none rather than the default which may inadvertently clash with something else.
0 new messages