public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "burnus at gcc dot gnu.org" <gcc-bugzilla@gcc.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	[thread overview]
Message-ID: <bug-55758-4@http.gcc.gnu.org/bugzilla/> (raw)


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


             reply	other threads:[~2012-12-20 15:07 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-20 15:07 burnus at gcc dot gnu.org [this message]
2013-01-09 16:21 ` [Bug fortran/55758] " burnus at gcc dot gnu.org
2013-02-26 14:41 ` burnus at gcc dot gnu.org
2014-03-22 19:22 ` dominiq at lps dot ens.fr
2015-09-05 10:31 ` dominiq at lps dot ens.fr

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-55758-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).