From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26547 invoked by alias); 10 Jan 2013 19:42:45 -0000 Received: (qmail 26457 invoked by uid 22791); 10 Jan 2013 19:42:43 -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-f41.google.com (HELO mail-la0-f41.google.com) (209.85.215.41) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 10 Jan 2013 19:42:38 +0000 Received: by mail-la0-f41.google.com with SMTP id em20so1034418lab.28 for ; Thu, 10 Jan 2013 11:42:36 -0800 (PST) MIME-Version: 1.0 Received: by 10.112.17.194 with SMTP id q2mr30072939lbd.7.1357846956859; Thu, 10 Jan 2013 11:42:36 -0800 (PST) Received: by 10.152.133.14 with HTTP; Thu, 10 Jan 2013 11:42:36 -0800 (PST) In-Reply-To: <50EC9EFF.8020706@net-b.de> References: <50DCCC29.6010206@net-b.de> <50E01A7C.2090106@net-b.de> <50E9ABC7.4040705@net-b.de> <50EC9EFF.8020706@net-b.de> Date: Thu, 10 Jan 2013 19:42: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: 2013-01/txt/msg00567.txt.bz2 On Wed, Jan 9, 2013 at 12:34 AM, Tobias Burnus wrote: > Janne Blomqvist worte: >> >> On Sun, Jan 6, 2013 at 6:52 PM, Tobias Burnus 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. Ah, thanks for the clarification. I think if we cannot make it really bullet-proof, then it's safer to reject it outright. Do you happen to know if anyone except openmpi would be affected? If only openmpi, then we could give them a nudge and the issue would likely be fixed by the time gcc 4.8 rolls out to end users. -- Janne Blomqvist