From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10150 invoked by alias); 29 Dec 2012 22:11:40 -0000 Received: (qmail 10129 invoked by uid 22791); 29 Dec 2012 22:11:38 -0000 X-SWARE-Spam-Status: No, hits=-5.1 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,KHOP_RCVD_TRUST,KHOP_THREADED,RCVD_IN_DNSWL_LOW,RCVD_IN_HOSTKARMA_YE X-Spam-Check-By: sourceware.org Received: from mail-la0-f47.google.com (HELO mail-la0-f47.google.com) (209.85.215.47) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 29 Dec 2012 22:11:33 +0000 Received: by mail-la0-f47.google.com with SMTP id fh20so2439144lab.34 for ; Sat, 29 Dec 2012 14:11:32 -0800 (PST) MIME-Version: 1.0 Received: by 10.112.36.161 with SMTP id r1mr15334872lbj.39.1356819092048; Sat, 29 Dec 2012 14:11:32 -0800 (PST) Received: by 10.152.133.14 with HTTP; Sat, 29 Dec 2012 14:11:31 -0800 (PST) In-Reply-To: <50DCCC29.6010206@net-b.de> References: <50DCCC29.6010206@net-b.de> Date: Sat, 29 Dec 2012 22:11:00 -0000 Message-ID: Subject: Re: [Patch, Fortran] PR55758 - Non-C_Bool handling with BIND(C) From: Janne Blomqvist To: Tobias Burnus Cc: gcc patches , gfortran Content-Type: text/plain; charset=UTF-8 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2012-12/txt/msg01472.txt.bz2 On Fri, Dec 28, 2012 at 12:31 AM, Tobias Burnus 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