This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Re: [Patch, Fortran] PR55758 - Non-C_Bool handling with BIND(C)
- From: Janne Blomqvist <blomqvist dot janne at gmail dot com>
- To: Tobias Burnus <burnus at net-b dot de>
- Cc: gcc patches <gcc-patches at gcc dot gnu dot org>, gfortran <fortran at gcc dot gnu dot org>
- Date: Sun, 30 Dec 2012 00:11:31 +0200
- Subject: Re: [Patch, Fortran] PR55758 - Non-C_Bool handling with BIND(C)
- References: <50DCCC29.6010206@net-b.de>
On Fri, Dec 28, 2012 at 12:31 AM, Tobias Burnus <burnus@net-b.de> wrote:
> Dear all,
>
> See also the discussion in the thread starting at
> http://gcc.gnu.org/ml/fortran/2012-12/msg00135.html
>
> a) The Fortran standard only defines LOGICAL(kind=C_Bool) as being
> interoperable with C - no other LOGICAL type. That matches GCC: With gcc
> (the C compiler) only _Bool is a BOOLEAN_TYPE with TYPE_PRECISION == 1.
> Hence, this patch rejects other logical kinds as dummy argument/result
> variable in BIND(C) procedures if -std=f2003/f2008/f2008ts is specified
> (using -pedantic, one gets a warning).
Sorry, I don't understand, what is the -pedantic warning about if it's
already rejected? Or do you mean std=gnu -pedantic?
> b) As GNU extension, other logical kinds are accepted in BIND(C) procedures;
> however, as the main use of "LOGICAL(kind=4)" (for BIND(C) procedures) is to
> handle logical expressions which use C's int, one has to deal with all
> integer values and not only 0 and 1. Hence, a normal integer type is used
> internally in that case. That has been done to avoid surprises of users and
> hard to trace bugs.
Does this actually work robustly? E.g. if you have a logical but
really integer under the covers, what happens if you equivalence it
with a "normal" logical variable. Or pass it as an argument to a
procedure expecting a normal logical etc. I suspect this might be
opening a can of worms..
--
Janne Blomqvist