[J3] Is BIND (C [ , NAME = scalar-default-char-constant-expr ]) where scalar-default-char-constant-expr has zero length legal?
Steidel, Jon L
jon.l.steidel at intel.com
Tue Jan 8 11:58:39 EST 2019
Hi Daniel,
If we don’t have the words in the document, then this may be a case of “implementation dependent” behavior. I will take a look and see if I can find words about this.
-jon
From: J3 [mailto:j3-bounces at mailman.j3-fortran.org] On Behalf Of Daniel C Chen via J3
Sent: Tuesday, January 8, 2019 11:47 AM
To: General J3 interest list <j3 at mailman.j3-fortran.org>
Cc: Daniel C Chen <cdchen at ca.ibm.com>
Subject: Re: [J3] Is BIND (C [ , NAME = scalar-default-char-constant-expr ]) where scalar-default-char-constant-expr has zero length legal?
Thanks Jon.
This makes sense and it is also the expected behavior of the user who reported this issue. XLF, however, ignores the BIND attribute at the moment. I couldn't find the wording in the standard that specifies the behavior you have though.
Daniel
XL Fortran Development, Fortran Standard Representative
IBM Toronto Software Lab
Phone: 905-413-3056
Tie: 969-3056
Email: cdchen at ca.ibm.com<mailto:cdchen at ca.ibm.com>
http://www.ibm.com/software/awdtools/fortran/xlfortran
[Inactive hide details for "Steidel, Jon L via J3" ---01/08/2019 11:31:59 AM---Hi Daniel, Ifort (and NAG 6.1) appear to treat th]"Steidel, Jon L via J3" ---01/08/2019 11:31:59 AM---Hi Daniel, Ifort (and NAG 6.1) appear to treat this as if NAME= was not specified. When I simplifie
From: "Steidel, Jon L via J3" <j3 at mailman.j3-fortran.org<mailto:j3 at mailman.j3-fortran.org>>
To: General J3 interest list <j3 at mailman.j3-fortran.org<mailto:j3 at mailman.j3-fortran.org>>
Cc: "Steidel, Jon L" <jon.l.steidel at intel.com<mailto:jon.l.steidel at intel.com>>
Date: 01/08/2019 11:31 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<mailto:j3-bounces at mailman.j3-fortran.org>>
________________________________
Hi Daniel,
Ifort (and NAG 6.1) appear to treat this as if NAME= was not specified. When I simplified the test case to
program main
use iso_c_binding
interface
subroutine foo (a) bind(c,name = "")
real a
end
end interface
call foo (1.0)
end
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.
-jon
From: J3 [mailto:j3-bounces at mailman.j3-fortran.org] On Behalf Of Daniel C Chen via J3
Sent: Tuesday, January 8, 2019 11:06 AM
To: General J3 interest list <j3 at mailman.j3-fortran.org<mailto:j3 at mailman.j3-fortran.org>>
Cc: Daniel C Chen <cdchen at ca.ibm.com<mailto:cdchen at ca.ibm.com>>
Subject: [J3] Is BIND (C [ , NAME = scalar-default-char-constant-expr ]) where scalar-default-char-constant-expr has zero length legal?
Consider the following code example:
module example
abstract interface
subroutine sighandler_t(signum) bind(c)
integer, value :: signum
end subroutine
end interface
contains
subroutine foo
call bar(sighandler)
end subroutine
subroutine bar(proc)
procedure(sighandler_t) :: proc
end subroutine
subroutine sighandler(signum) bind(c,name='') ! NAME has zero length
integer, value :: signum
print *, signum
end subroutine sighandler
end module
At 8.5.5, the standard says
R808 language-binding-spec is BIND (C [ , NAME = scalar-default-char-constant-expr ])
...
"If the value of the scalar-default-char-constant-expr after discarding leading and trailing blanks has nonzero
length, it shall be valid as an identifier on the companion processor."
But 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?
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<mailto:cdchen at ca.ibm.com>
http://www.ibm.com/software/awdtools/fortran/xlfortran
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.j3-fortran.org/pipermail/j3/attachments/20190108/f6f08f4d/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.gif
Type: image/gif
Size: 105 bytes
Desc: image001.gif
URL: <https://mailman.j3-fortran.org/pipermail/j3/attachments/20190108/f6f08f4d/attachment.gif>
More information about the J3
mailing list