This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [Patch, Fortran] PR55758 - Non-C_Bool handling with BIND(C)


Janne Blomqvist worte:
On Sun, Jan 6, 2013 at 6:52 PM, Tobias Burnus<burnus@net-b.de> wrote:
>Attached is a small variation, which in addition handles the case that a
>non-BOOL_C LOGICAL, Bind(C) dummy argument (or result variable) is used in a
>procedure call. In that case, the variable is now converted to a
>TYPE_PRECISION == 1 variable. -- The updated patch was build and regtested
>successfully.
Nice, this should fix a pitfall with the previous patch. I still worry
about these almost-but-not-quite logicals causing weird and very hard
to track down bugs.

Though, it should be much less severe then with the current trunk.


A slightly safer variant of the approach youdescribe above would be to convert the variable directly after the bind(c) procedure call; that should make it pretty fool-proof, AFAICS?
(in some cases that would be a bit of extra useless work, but I doubt
it would matter performance-wise).

Well, that's not at trivial as it sounds. In particular for a Fortran-written procedure, which gets the input from C. If the variable is INTENT(IN) or if it is not modified in the procedure, it may not be touched. In order to do this, one has to implement support for a shadow variable, which has to set the real one at the end of the procedure. I don't think that this shadow-var handling is really that trivial.


For actual arguments, doing the conversion back is simpler. Function results might be also a bit tricky, but that's mostly handled by the current patch, I hope.

Tobias


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]