From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9832 invoked by alias); 20 Dec 2012 15:07:33 -0000 Received: (qmail 7612 invoked by uid 48); 20 Dec 2012 15:07:09 -0000 From: "burnus at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/55758] New: LOGICAL and BIND(C): Reject kind=2/4/8/16 with -std=f2008, improve warning, switch to nonBOOLEAN_TYPE for those Date: Thu, 20 Dec 2012 15:07:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: fortran X-Bugzilla-Keywords: accepts-invalid, diagnostic X-Bugzilla-Severity: normal X-Bugzilla-Who: burnus at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2012-12/txt/msg01985.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55758 Bug #: 55758 Summary: LOGICAL and BIND(C): Reject kind=2/4/8/16 with -std=f2008, improve warning, switch to nonBOOLEAN_TYPE for those Classification: Unclassified Product: gcc Version: 4.8.0 Status: UNCONFIRMED Keywords: accepts-invalid, diagnostic Severity: normal Priority: P3 Component: fortran AssignedTo: unassigned@gcc.gnu.org ReportedBy: burnus@gcc.gnu.org See http://gcc.gnu.org/ml/fortran/2012-12/threads.html#00135 In the Fortran standard, only LOGICALs of kind C_BOOL interoperate with C; namely, with C99's _Bool/bool. In C, also integers - in particular "int" - are used in Boolean expressions, allows for the whole range of integral values - all are "true" except for 0 which is "false". gcc's _Bool and gfortran's LOGICAL all assume a binary state (BOOLEAN_TYPE) which is either 0 or 1 such that .NOT. can be implemented by flipping a single bit. Hence, regarding an "int" as BOOLEAN_TYPE leads to .NOT.(-1) = -2. Currently, LOGICAL(kind=C_INT) (c_int == 4) is accepted by gfortran and C binding, but it might lead to wrong results with .NOT. Expected: * With -std=f95/f2003/f2008/f2008tr, only LOGICAL with kind=C_BOOL (C_BOOL == 1) is accepted * With -std=gnu, also the others (2,4,8,16) are accepted but a warning is printed for them. * Consider replacing internally BOOLEAN_TYPE by a signed-integer type LOGICAL with kind /= C_BOOL in procedures with C binding