Fwd: Re: [Patch][Fortran] On unformatted read, convert != 0 logical to 1

Tobias Burnus tobias@codesourcery.com
Mon Jan 27 17:02:00 GMT 2020


Just saw that gcc-patches@ wasn't included in the list. See: 
https://gcc.gnu.org/ml/fortran/2020-01/threads.html#00088 for the thread.

Tobias

-------- Forwarded Message --------
Subject: 	Re: [Patch][Fortran] On unformatted read, convert != 0 logical 
to 1
Date: 	Mon, 27 Jan 2020 17:29:10 +0100
From: 	Tobias Burnus <tobias@codesourcery.com>
To: 	Tobias Burnus <tobias@codesourcery.com>, Thomas Koenig 
<tkoenig@netcologne.de>, Janne Blomqvist <blomqvist.janne@gmail.com>
CC: 	Richard Biener <richard.guenther@gmail.com>, Marco Jacopo 
Ferrarotti <marco.ferrarotti@gmail.com>, fortran@gcc.gnu.org 
<fortran@gcc.gnu.org>, Jerry DeLisle <jvdelisle@charter.net>



On 1/27/20 9:58 AM, Tobias Burnus wrote:
> I think (3) with (a) and only (iii) is my preferred combination, but I 
> am also open for other suggestions.

That's now what the attached patch does.

RFC: Should this option use "!= 0" as .true. or "(var % 2) == 1" as 
.true.? – Either works for the ubiquitous 0 = .false. plus both 1 
(gfortran, ifort –standard-semantics, …) and –1 (ifort, PGI, …) as 
.true. [Other values can only occur when modifying the value directly, 
which should be done in a proper program, or if interop goes wrong with 
.not.. (".true.(1) xor -1" or ".true.(-1) xor 1")]

I have used != 0 – and placed it before the endian conversion ("else 
if"). For the even/odd check, it has to be after the endian conversion.

Besides != 0 and even/odd, one could also change the Boolean flag into a 
three-state flag, using != 0 or even/odd at the user's discretion but 
that seems to be overkill.

What do you think?

Tobias

PS: Minor changes: libgomp.texi — I removed some tailing "." in the 
@menu for consistency. And in libgfortran.h, I put "optional_plus" into 
another like to avoid mixing Boolean and integer items. One could change 
optional_plus, locus, all_unbuffered, unbuffered_preconnect, backtrace, 
legacy_logical_read, backtrace to "bool" and moving the bool and the 
char item together, saving 8*4 - 8*1 = 24 bytes. [However, the type is 
only used once for static variable.]
-------------- next part --------------
A non-text attachment was scrubbed...
Name: io-logical-write-v2.diff
Type: text/x-patch
Size: 15398 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20200127/6c3e8d59/attachment.bin>


More information about the Gcc-patches mailing list