public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [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
@ 2012-12-20 15:07 burnus at gcc dot gnu.org
  2013-01-09 16:21 ` [Bug fortran/55758] " burnus at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: burnus at gcc dot gnu.org @ 2012-12-20 15:07 UTC (permalink / raw)
  To: gcc-bugs


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


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug fortran/55758] LOGICAL and BIND(C): Reject kind=2/4/8/16 with -std=f2008, improve warning, switch to nonBOOLEAN_TYPE for those
  2012-12-20 15:07 [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 burnus at gcc dot gnu.org
@ 2013-01-09 16:21 ` burnus at gcc dot gnu.org
  2013-02-26 14:41 ` burnus at gcc dot gnu.org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: burnus at gcc dot gnu.org @ 2013-01-09 16:21 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55758

--- Comment #1 from Tobias Burnus <burnus at gcc dot gnu.org> 2013-01-09 16:20:42 UTC ---
Author: burnus
Date: Wed Jan  9 16:20:33 2013
New Revision: 195055

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=195055
Log:
2013-01-09  Tobias Burnus  <burnus@net-b.de>

        PR fortran/55758
        * resolve.c (resolve_symbol): Reject non-C_Bool logicals
        in BIND(C) procedures with -std=f*.

2013-01-09  Tobias Burnus  <burnus@net-b.de>

        PR fortran/55758
        * gfortran.dg/bind_c_bool_1.f90: New.
        * gfortran.dg/do_5.f90: Add dg-warning.


Added:
    trunk/gcc/testsuite/gfortran.dg/bind_c_bool_1.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/resolve.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/gfortran.dg/do_5.f90


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug fortran/55758] LOGICAL and BIND(C): Reject kind=2/4/8/16 with -std=f2008, improve warning, switch to nonBOOLEAN_TYPE for those
  2012-12-20 15:07 [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 burnus at gcc dot gnu.org
  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
  3 siblings, 0 replies; 5+ messages in thread
From: burnus at gcc dot gnu.org @ 2013-02-26 14:41 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55758

Tobias Burnus <burnus at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |burnus at gcc dot gnu.org

--- Comment #2 from Tobias Burnus <burnus at gcc dot gnu.org> 2013-02-26 14:41:07 UTC ---
Note that MPI 3 currently uses a default-kind LOGICAL with BIND(C), cf.
http://lists.mpi-forum.org/mpi-comments/2013/02/0076.php


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug fortran/55758] LOGICAL and BIND(C): Reject kind=2/4/8/16 with -std=f2008, improve warning, switch to nonBOOLEAN_TYPE for those
  2012-12-20 15:07 [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 burnus at gcc dot gnu.org
  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
  3 siblings, 0 replies; 5+ messages in thread
From: dominiq at lps dot ens.fr @ 2014-03-22 19:22 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55758

Dominique d'Humieres <dominiq at lps dot ens.fr> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |WAITING
   Last reconfirmed|                            |2014-03-22
     Ever confirmed|0                           |1

--- Comment #3 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
What remains to be fixed? If anything, is it related to pr47605?


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug fortran/55758] LOGICAL and BIND(C): Reject kind=2/4/8/16 with -std=f2008, improve warning, switch to nonBOOLEAN_TYPE for those
  2012-12-20 15:07 [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 burnus at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2014-03-22 19:22 ` dominiq at lps dot ens.fr
@ 2015-09-05 10:31 ` dominiq at lps dot ens.fr
  3 siblings, 0 replies; 5+ messages in thread
From: dominiq at lps dot ens.fr @ 2015-09-05 10:31 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55758

Dominique d'Humieres <dominiq at lps dot ens.fr> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|WAITING                     |RESOLVED
         Resolution|---                         |FIXED

--- Comment #4 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
> What remains to be fixed? If anything, is it related to pr47605?

No answer since a year and a half. Closing as FIXED. Please open new PR(s) for
remaining issue(s).


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-09-05 10:31 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-12-20 15:07 [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 burnus at gcc dot gnu.org
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

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).