Bug 29784 - [doc] No I/O conversion of logical/integer
Summary: [doc] No I/O conversion of logical/integer
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.3.0
: P3 trivial
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: documentation
Depends on:
Blocks:
 
Reported: 2006-11-09 17:28 UTC by Tobias Burnus
Modified: 2007-10-25 23:27 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2007-10-24 09:44:40


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tobias Burnus 2006-11-09 17:28:57 UTC
Currently, gfortran supports
   integer = logical
and
   logical = integer
with a default warning
"Extension: Conversion from INTEGER(4) to LOGICAL(4) at (1)"

However, some compilers also support:
   print '(i0)', logical
gfortran currently gives:
"Fortran runtime error: Expected INTEGER for item 1 in formatted transfer, got LOGICAL"

Other compilers:
- g95 and NAG f95 give always a run-time error
- Intel supports it (no warning; .true. is -1, .false.; int even = false, int  odd = true); printing logical = 10, shows "10".
- sunf95: Assignment not supported (compile-time error), but '(i0)' is supported ("1" and "0", 0 = .false., 0 /= .true.)
- At least IO is also supported by g77, IBM xlf and HP/UX fort77
cf. http://gcc.gnu.org/ml/fortran/2006-11/msg00274.html

Expected:
(a) We explicitly state that this is not supported for IO.

(b) We support '(i0)' for logical and document this also in "7.11 Implicitly interconvert LOGICAL and INTEGER" and continue to give for -std=f95/f2003 a run-time error, i.e. changing in io/transfer.c's formatted_transfer_scalar along these lines:
case FMT_I: [...]
          if (require_type (dtp, BT_INTEGER, type, f))
-           return;
+          {
+            if (compile_options.allow_std < GFC_STD_GNU
+              && require_type (dtp, BT_LOGICAL, type, f))
+              return;
+          }

Maybe one could also use GFC_STD_LEGACY instead of GFC_STD_GNU.

I don't know whether one needs also to change something for READing or whether one wants to support reading.
Comment 1 Francois-Xavier Coudert 2007-10-24 09:44:40 UTC
We should document the current situation and close this (http://gcc.gnu.org/ml/fortran/2007-10/msg00263.html).
Comment 2 Francois-Xavier Coudert 2007-10-25 23:27:23 UTC
Subject: Bug 29784

Author: fxcoudert
Date: Thu Oct 25 23:27:12 2007
New Revision: 129635

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=129635
Log:
	PR fortran/29784
	* gfortran.texi: Document that there is no logical/integer
	conversion performed during I/O operations.

Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/gfortran.texi

Comment 3 Francois-Xavier Coudert 2007-10-25 23:27:51 UTC
Fixed.