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.
We should document the current situation and close this (http://gcc.gnu.org/ml/fortran/2007-10/msg00263.html).
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
Fixed.