public inbox for fortran@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jerry D <jvdelisle2@gmail.com>
To: Tobias Burnus <tburnus@baylibre.com>, gfortran <fortran@gcc.gnu.org>
Cc: gcc-patches <gcc-patches@gcc.gnu.org>
Subject: Re: [patch, libgfortran] PR114304 - [13/14 Regression] libgfortran I/O – bogus "Semicolon not allowed as separator with DECIMAL='point'"
Date: Thu, 4 Apr 2024 13:05:59 -0700	[thread overview]
Message-ID: <63b8d035-47cf-4d1d-9df1-8337d85070c1@gmail.com> (raw)
In-Reply-To: <b4e78a90-40bc-421f-811e-fe446ab0772c@baylibre.com>

On 4/4/24 2:31 AM, Tobias Burnus wrote:
> Hi Jerry,
> 
> Jerry D wrote:
>> The attached log entry and patch (git show) fixes this issue by adding 
>> logic to handle spaces in eat_separators. One or more spaces by 
>> themselves are a valid separator. So in this case we look at the 
>> character following the spaces to see if it is a comma or semicolon.
>>
>> If so, I change it to the valid separator for the given decimal mode, 
>> point or comma. This allows the comma or semicolon to be interpreted 
>> as a null read on the next effective item in the formatted read.
>>
>> I chose a permissive approach here that allows reads to proceed when the
>> input line is mal-formed with an incorrect separator as long as there 
>> is at least one space in front of it.
> 
> First: Consider also adding 'PR fortran/105473' to the commit log
> as the PRs are closely related, albeit this PR is different-
> 
> The patch looks mostly like I would expect, except for decimal='point' 
> and a ';' which is *not* preceded by a space.
> 
> Thanks for working on it.
> 
> Regarding the 'except' case:
> 
> * * *
> 
> If I try your patch with the testcase of at comment 19,
> 
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114304#c19
> → https://gcc.gnu.org/bugzilla/attachment.cgi?id=57695 ,
> 
> I do note that with 'decimal=point', a tailing semicolon is silently
> accepted – even if not proceeded by a space.

I did that on purpose out of leniency and fear of breaking something.  I 
will add that in and do some testing.

> 
> I think such code is invalid – and you could consider to reject it.
> Otherwise, the handling all seems to be in line with the Fortran spec.
> 
> i.e. for the following string, I had *expected an error*:

I will see what it does. I agree in principle.

> 
>   point, isreal =  F , testinput = ";"n=          42  ios=           0
>   point, isreal =  F , testinput = "5;"n=           5  ios=           0
>   point, isreal =  T , testinput = "8;"r=   8.00000000      ios= 0
>   point, isreal =  T , testinput = "3.3;"r=   3.29999995      ios= 0
>   point, isreal =  T , testinput = "3,3;"r=   3.00000000      ios= 0
> 
> while I think the following is OK (i.e. no error is what I expect) due 
> to the the space before the ';'.

Agree and this is what I was attempting.

> 
>   point, isreal =  F , testinput = "7 ;"n=           7  ios= 0
>   point, isreal =  T , testinput = "9 ;"r=   9.00000000      ios= 0
>   point, isreal =  T , testinput = "4.4 ;"r=   4.40000010      ios=0
>   point, isreal =  T , testinput = "9 ;"r=   9.00000000      ios= 0
>   point, isreal =  T , testinput = "4,4 ;"r=   4.00000000      ios= 0
> 
> * * *
> 
> Looking at the other compilers, ifort, ifx and Flang do issue an error 
> here. Likewise, g95 seems to yield an error in this case (see below).
> 
> I do note that the Lapack testcase that triggered this PR did have such 
> a code - but it was then changed because g95 did not like it:
> 
> https://github.com/Reference-LAPACK/lapack/commit/64e8a7500d817869e5fcde35afd39af8bc7a8086
> 

I am glad they fixed that, it triggered a whole lot of cycles here.

> In terms of gfortran: until recently did accept it (all versions, 
> including 13+14); it then rejected it due to the change in PR105473 (GCC 
> 14/mainline, backported to 13)– but I now think it rightly did so. With 
> the current patch, it is accepted again.
> 
> * * *
> 
> I have attached the modified testcase linked above; consider adding it 
> as well. - Changes to the one of the attachment:
> - I added a few additional (albeit boring) tests
> - I added an expected output + error diagnostic.
> 
> The testcase assumes an error for ';' as separator (with 'point'), 
> unless there is a space before it.
> 
> [If we want to not diagnose this as vendor extension, we really need to 
> add a comment to that testcase besides changing valid = .false. to .true.]

I have gone back and forth on this issue many times trying to find the 
middle ground. The standard is fairly clear. To me it is on the user to 
not use malformed input so allowing with the intervening space we are 
simply ignoring the trailing ',' or ';' and calling the spaces 
sufficient as a valid separator.

Regardless I now have your modified test case passing. Much appreciated.

Thanks for the reviews.  I will resubmit when I can, hopefully today.

Cheers,

Jerry




  reply	other threads:[~2024-04-04 20:06 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-04  1:33 Jerry D
2024-04-04  8:17 ` Paul Richard Thomas
2024-04-04  9:31 ` Tobias Burnus
2024-04-04 20:05   ` Jerry D [this message]
2024-04-04 21:04   ` Jerry D
2024-04-04 21:41     ` Tobias Burnus
2024-04-05 17:47       ` Jerry D
2024-04-06  2:38         ` Jerry D
2024-04-06  5:17           ` Tobias Burnus
2024-04-08  9:53           ` [Patch] Fortran: List-directed read - accept again tab as alternative to space as separator [PR114304] (was: [patch, libgfortran] PR114304 - [13/14 Regression] libgfortran I/O – bogus "Semicolon not allowed as separator with DECIMAL='point'") Tobias Burnus
2024-04-08 18:21             ` [Patch] Fortran: List-directed read - accept again tab as alternative to space as separator [PR114304] Jerry D

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=63b8d035-47cf-4d1d-9df1-8337d85070c1@gmail.com \
    --to=jvdelisle2@gmail.com \
    --cc=fortran@gcc.gnu.org \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=tburnus@baylibre.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).