[J3] Is BIND (C [ , NAME = scalar-default-char-constant-expr ]) where scalar-default-char-constant-expr has zero length legal?
Daniel C Chen
cdchen at ca.ibm.com
Wed Jan 9 11:27:23 EST 2019
Yeah, it is indeed the same issue as 16-161.
Based on the wording in the standard that Bill pointed out,
1. subroutine 'foo' has the BIND attribute, but no binding label. So 'foo'
can be called within Fortran, but 'foo' must not be referenced in C due to
lack of a binding label.
2. If "subroutine foo() bind(c, name='')" is in an interface, Fortran
cannot call a C routine named 'foo' as well.
Thanks,
Daniel
XL Fortran Development, Fortran Standard Representative
IBM Toronto Software Lab
Phone: 905-413-3056
Tie: 969-3056
Email: cdchen at ca.ibm.com
http://www.ibm.com/software/awdtools/fortran/xlfortran
From: Steve Lionel via J3 <j3 at mailman.j3-fortran.org>
To: General J3 interest list <j3 at mailman.j3-fortran.org>
Cc: Steve Lionel <steve at stevelionel.com>
Date: 01/09/2019 09:01 AM
Subject: Re: [J3] Is BIND (C [ , NAME =
scalar-default-char-constant-expr ]) where
scalar-default-char-constant-expr has zero length legal?
Sent by: "J3" <j3-bounces at mailman.j3-fortran.org>
Isn't this the subject of 16-161r1 from meeting 209? My notes say No action
(15.10.2 says "no binding label")
Steve
On Tue, Jan 8, 2019 at 6:03 PM Bill Long via J3 <j3 at mailman.j3-fortran.org>
wrote:
> On Jan 8, 2019, at 2:20 PM, Daniel C Chen via J3 <
j3 at mailman.j3-fortran.org> wrote:
>
> Hi Bill and Vipul,
>
> It is down to if "subroutine foo() bind(c, name='')" should be treated
as:
> 1. subroutine foo() bind(c), or
> 2. subroutine foo()
3) Neither.
Option 1 says that there is a binding label with the value ‘foo’.
Option 2 says no binding label and no BIND(C) semantics.
Option 3 is for no binding label, but with the BIND(C) semantics. That
is what corresponds to specifying bind(c,name=s) where s is a character
variable with zero length of all blank characters.
>
> BIND attribute is part of the characteristic of a procedure, so option
1 and options 2 are significantly different.
Correct.
>
> It seems option 1 is preferred, and I think it makes more sense too.
The problem is I couldn't find any wording in the standard that makes it
clear.
18.10.2 para 2.
Cheers,
Bill
>
> Thanks,
>
> Daniel
>
> XL Fortran Development, Fortran Standard Representative
> IBM Toronto Software Lab
> Phone: 905-413-3056
> Tie: 969-3056
> Email: cdchen at ca.ibm.com
> http://www.ibm.com/software/awdtools/fortran/xlfortran
>
> <graycol.gif>Vipul Parekh via J3 ---01/08/2019 03:01:48 PM---On Tue,
Jan 8, 2019 at 11:06 AM Daniel C Chen via J3 <j3 at mailman.j3-fortran.org>
wrote:
>
> From: Vipul Parekh via J3 <j3 at mailman.j3-fortran.org>
> To: General J3 interest list <j3 at mailman.j3-fortran.org>
> Cc: Vipul Parekh <parekhvs at gmail.com>
> Date: 01/08/2019 03:01 PM
> Subject: Re: [J3] Is BIND (C [ , NAME =
scalar-default-char-constant-expr ]) where
scalar-default-char-constant-expr has zero length legal?
> Sent by: "J3" <j3-bounces at mailman.j3-fortran.org>
>
>
>
>
> On Tue, Jan 8, 2019 at 11:06 AM Daniel C Chen via J3
> <j3 at mailman.j3-fortran.org> wrote:
> >
> > .. the standard doesn't specify what if the
scalar-default-char-constant-exprhas zero length.
> >
> > Question: Should it be treated
> > 1. as if the NAME specified is not specified or
> > 2. the compiler should ignore the BIND attribute all together?
> >
>
> Hi Daniel,
>
> You must have seen Jon's and Bill's responses. Just for your
> reference, here's a (related?) thread from comp,lang.fortran on NAME
> specifier with BIND attribute:
>
https://groups.google.com/d/msg/comp.lang.fortran/x3hMN4chYtc/ewskOS5oDAAJ
>
>
> On Tue, Jan 8, 2019 at 11:31 AM Steidel, Jon L via J3
> <j3 at mailman.j3-fortran.org> wrote:
> > ..
> > Both compilers compile without error or warning, and fail in the
link/load step with an undefined reference to “foo” or “foo_”. So it
looks like the Fortran name is used when NAME= is a zero length string.
> > ..
>
> Hi Jon,
>
> Interestingly and (dare I say!) correctly and thankfully, your example
> compiled using Intel Fortran can be linked with the object created by
> that same compiler toward this code on Windows x64 platform
>
> subroutine foo( arg ) bind(C, name="foo")
> real arg
> print *, "foo: arg = ", arg
> end subroutine
>
> and executed to produce the following output:
>
> foo: arg = 1.000000
>
> Regards,
> Vipul
>
>
>
>
Bill Long
longb at cray.com
Principal Engineer, Fortran Technical Support & voice: 651-605-9024
Bioinformatics Software Development fax:
651-605-9143
Cray Inc./ 2131 Lindau Lane/ Suite 1000/ Bloomington, MN 55425
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.j3-fortran.org/pipermail/j3/attachments/20190109/4457b9e6/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: graycol.gif
Type: image/gif
Size: 105 bytes
Desc: not available
URL: <https://mailman.j3-fortran.org/pipermail/j3/attachments/20190109/4457b9e6/attachment-0001.gif>
More information about the J3
mailing list