This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libfortran/29784] New: Converting logical <-> integer in IO


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.


-- 
           Summary: Converting logical <-> integer in IO
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: libfortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: burnus at gcc dot gnu dot org


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]