public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/109662] New: bad namelist input but gfortran accepted it
@ 2023-04-28  8:20 john.harper at vuw dot ac.nz
  2023-04-28 21:20 ` [Bug libfortran/109662] " anlauf at gcc dot gnu.org
                   ` (21 more replies)
  0 siblings, 22 replies; 23+ messages in thread
From: john.harper at vuw dot ac.nz @ 2023-04-28  8:20 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109662

            Bug ID: 109662
           Summary: bad namelist input but gfortran accepted it
           Product: gcc
           Version: 12.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: john.harper at vuw dot ac.nz
  Target Milestone: ---

This program compiled and ran with the std=f2018 option though it has a comma
between the namelist group name and the variable name, which I and ifort
believe is non-standard. The program:

program testnmlread
  use iso_fortran_env,only: compiler_version,compiler_options,output_unit
  implicit none
  character(16) :: list = '&stuff, n = 666/'
  integer       :: n
  namelist/stuff/n
  print *,'Compiler version = ',trim(compiler_version())
  print *,'Compiler options = ',trim(compiler_options())
  read(list,nml=stuff)
  write(output_unit,nml=stuff)
end program testnmlread

The output:

 Compiler version = GCC version 12.1.0
 Compiler options = -mtune=generic -march=x86-64 -g -std=f2018
-fpre-include=/usr/include/finclude/math-vector-fortran.h
&STUFF
 N=666        ,
 /

Result of gfortran -v :

Using built-in specs.
COLLECT_GCC=gfortran-12
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/12/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none:amdgcn-amdhsa
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu
12.1.0-2ubuntu1~22.04' --with-bugurl=file:///usr/share/doc/gcc-12/README.Bugs
--enable-languages=c,ada,c++,go,d,fortran,objc,obj-c++,m2 --prefix=/usr
--with-gcc-major-version-only --program-suffix=-12
--program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug
--enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new
--enable-gnu-unique-object --disable-vtable-verify --enable-plugin
--enable-default-pie --with-system-zlib --enable-libphobos-checking=release
--with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch
--disable-werror --enable-cet --with-arch-32=i686 --with-abi=m64
--with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic
--enable-offload-targets=nvptx-none=/build/gcc-12-sZcx2y/gcc-12-12.1.0/debian/tmp-nvptx/usr,amdgcn-amdhsa=/build/gcc-12-sZcx2y/gcc-12-12.1.0/debian/tmp-gcn/usr
--enable-offload-defaulted --without-cuda-driver --enable-checking=release
--build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 12.1.0 (Ubuntu 12.1.0-2ubuntu1~22.04)

^ permalink raw reply	[flat|nested] 23+ messages in thread

* [Bug libfortran/109662] bad namelist input but gfortran accepted it
  2023-04-28  8:20 [Bug fortran/109662] New: bad namelist input but gfortran accepted it john.harper at vuw dot ac.nz
@ 2023-04-28 21:20 ` anlauf at gcc dot gnu.org
  2023-04-30 22:40 ` kargl at gcc dot gnu.org
                   ` (20 subsequent siblings)
  21 siblings, 0 replies; 23+ messages in thread
From: anlauf at gcc dot gnu.org @ 2023-04-28 21:20 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109662

anlauf at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|fortran                     |libfortran
   Last reconfirmed|                            |2023-04-28
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW

--- Comment #1 from anlauf at gcc dot gnu.org ---
I also interpret F2018:13.11.3.1 that a value-separator may follow only
a name-value subsequence but not immediately the namelist-group-name.
This is also what other brands (NAG, Intel, Nvidia) accept.

Thus confirmed.

^ permalink raw reply	[flat|nested] 23+ messages in thread

* [Bug libfortran/109662] bad namelist input but gfortran accepted it
  2023-04-28  8:20 [Bug fortran/109662] New: bad namelist input but gfortran accepted it john.harper at vuw dot ac.nz
  2023-04-28 21:20 ` [Bug libfortran/109662] " anlauf at gcc dot gnu.org
@ 2023-04-30 22:40 ` kargl at gcc dot gnu.org
  2023-05-01  0:37 ` jvdelisle at gcc dot gnu.org
                   ` (19 subsequent siblings)
  21 siblings, 0 replies; 23+ messages in thread
From: kargl at gcc dot gnu.org @ 2023-04-30 22:40 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109662

kargl at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |kargl at gcc dot gnu.org

--- Comment #2 from kargl at gcc dot gnu.org ---
(In reply to anlauf from comment #1)
> I also interpret F2018:13.11.3.1 that a value-separator may follow only
> a name-value subsequence but not immediately the namelist-group-name.
> This is also what other brands (NAG, Intel, Nvidia) accept.
> 
> Thus confirmed.

Yes, definitely a bug.  The issue isn't the value-separator.  It's
item (3) from 13.11.3.1.

    Input for a namelist input statement consists of

        (1) optional blanks and namelist comments,
        (2) the character & followed immediately by the
            namelist-group-name as specified in the NAMELIST
            statement,
        (3) one or more blanks,

There needs to be a blank following '&stuff'.  Now, the question
becomes "what happens with this line?"

  character(17) :: list = '&stuff , n = 666/'

The next requirement comes into play
        (4) a sequence of zero or more name-value subsequences
            separated by value separators, and

Probably should tag Jerry.

^ permalink raw reply	[flat|nested] 23+ messages in thread

* [Bug libfortran/109662] bad namelist input but gfortran accepted it
  2023-04-28  8:20 [Bug fortran/109662] New: bad namelist input but gfortran accepted it john.harper at vuw dot ac.nz
  2023-04-28 21:20 ` [Bug libfortran/109662] " anlauf at gcc dot gnu.org
  2023-04-30 22:40 ` kargl at gcc dot gnu.org
@ 2023-05-01  0:37 ` jvdelisle at gcc dot gnu.org
  2023-05-01  3:05 ` jvdelisle at gcc dot gnu.org
                   ` (18 subsequent siblings)
  21 siblings, 0 replies; 23+ messages in thread
From: jvdelisle at gcc dot gnu.org @ 2023-05-01  0:37 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109662

Jerry DeLisle <jvdelisle at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jvdelisle at gcc dot gnu.org
           Assignee|unassigned at gcc dot gnu.org      |jvdelisle at gcc dot gnu.org

--- Comment #3 from Jerry DeLisle <jvdelisle at gcc dot gnu.org> ---
I have to say it.  We have not seen a NAMELIST bug in a long time. I will take
it.

^ permalink raw reply	[flat|nested] 23+ messages in thread

* [Bug libfortran/109662] bad namelist input but gfortran accepted it
  2023-04-28  8:20 [Bug fortran/109662] New: bad namelist input but gfortran accepted it john.harper at vuw dot ac.nz
                   ` (2 preceding siblings ...)
  2023-05-01  0:37 ` jvdelisle at gcc dot gnu.org
@ 2023-05-01  3:05 ` jvdelisle at gcc dot gnu.org
  2023-05-04  3:05 ` jvdelisle at gcc dot gnu.org
                   ` (17 subsequent siblings)
  21 siblings, 0 replies; 23+ messages in thread
From: jvdelisle at gcc dot gnu.org @ 2023-05-01  3:05 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109662

--- Comment #4 from Jerry DeLisle <jvdelisle at gcc dot gnu.org> ---
I knew this looked familiar.  We did it on purpose.  From list_read.c:

  /* A trailing space is required, we give a little latitude here, 10.9.1.  */
  c = next_char (dtp);
  if (!is_separator(c) && c != '!')
    {
      unget_char (dtp, c);
      goto find_nml_name;
    }

I think we allowed sepraators for some old legacy stuff.  I will make
adjustments.

^ permalink raw reply	[flat|nested] 23+ messages in thread

* [Bug libfortran/109662] bad namelist input but gfortran accepted it
  2023-04-28  8:20 [Bug fortran/109662] New: bad namelist input but gfortran accepted it john.harper at vuw dot ac.nz
                   ` (3 preceding siblings ...)
  2023-05-01  3:05 ` jvdelisle at gcc dot gnu.org
@ 2023-05-04  3:05 ` jvdelisle at gcc dot gnu.org
  2023-05-04  4:59 ` john.harper at vuw dot ac.nz
                   ` (16 subsequent siblings)
  21 siblings, 0 replies; 23+ messages in thread
From: jvdelisle at gcc dot gnu.org @ 2023-05-04  3:05 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109662

--- Comment #5 from Jerry DeLisle <jvdelisle at gcc dot gnu.org> ---
Is this acceptable:

$ ./a.out 
 Compiler version = GCC version 14.0.0 20230424 (experimental)
 Compiler options = -mtune=generic -march=x86-64 -Wpedantic
-fpre-include=/usr/include/finclude/math-vector-fortran.h
At line 9 of file pr109662.f90
Fortran runtime error: Comma after namelist name not allowed

Should I allow it with -std=legacy?

^ permalink raw reply	[flat|nested] 23+ messages in thread

* [Bug libfortran/109662] bad namelist input but gfortran accepted it
  2023-04-28  8:20 [Bug fortran/109662] New: bad namelist input but gfortran accepted it john.harper at vuw dot ac.nz
                   ` (4 preceding siblings ...)
  2023-05-04  3:05 ` jvdelisle at gcc dot gnu.org
@ 2023-05-04  4:59 ` john.harper at vuw dot ac.nz
  2023-05-04  6:00 ` john.harper at vuw dot ac.nz
                   ` (15 subsequent siblings)
  21 siblings, 0 replies; 23+ messages in thread
From: john.harper at vuw dot ac.nz @ 2023-05-04  4:59 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109662

--- Comment #6 from john.harper at vuw dot ac.nz ---
OK by me but I'm not in charge of gfortran!

On Thu, 4 May 2023, jvdelisle at gcc dot gnu.org wrote:

> Date: Thu, 4 May 2023 03:05:49 +0000
> From: jvdelisle at gcc dot gnu.org <gcc-bugzilla@gcc.gnu.org>
> To: John Harper <john.harper@vuw.ac.nz>
> Subject: [Bug libfortran/109662] bad namelist input but gfortran accepted it
> Resent-Date: Thu, 4 May 2023 15:05:59 +1200 (NZST)
> Resent-From: <john.harper@vuw.ac.nz>
> 
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109662
>
> --- Comment #5 from Jerry DeLisle <jvdelisle at gcc dot gnu.org> ---
> Is this acceptable:
>
> $ ./a.out
> Compiler version = GCC version 14.0.0 20230424 (experimental)
> Compiler options = -mtune=generic -march=x86-64 -Wpedantic
> -fpre-include=/usr/include/finclude/math-vector-fortran.h
> At line 9 of file pr109662.f90
> Fortran runtime error: Comma after namelist name not allowed
>
> Should I allow it with -std=legacy?
>
> -- 
> You are receiving this mail because:
> You reported the bug.
>


-- John Harper, School of Mathematics and Statistics
Victoria Univ. of Wellington, PO Box 600, Wellington 6140, New Zealand.
e-mail john.harper@vuw.ac.nz phone +64(0) 4 463 5276

^ permalink raw reply	[flat|nested] 23+ messages in thread

* [Bug libfortran/109662] bad namelist input but gfortran accepted it
  2023-04-28  8:20 [Bug fortran/109662] New: bad namelist input but gfortran accepted it john.harper at vuw dot ac.nz
                   ` (5 preceding siblings ...)
  2023-05-04  4:59 ` john.harper at vuw dot ac.nz
@ 2023-05-04  6:00 ` john.harper at vuw dot ac.nz
  2023-05-05  2:44 ` jvdelisle at gcc dot gnu.org
                   ` (14 subsequent siblings)
  21 siblings, 0 replies; 23+ messages in thread
From: john.harper at vuw dot ac.nz @ 2023-05-04  6:00 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109662

--- Comment #7 from john.harper at vuw dot ac.nz ---
I hadn't thought about -std=gnu in this context but it would make sense
for std=gnu to give a warning for comma after namelist name if 
std=legacy is going to allow it without one. You wouldn't then have to 
change the gfortran manual page.

John

On Thu, 4 May 2023, John Harper wrote:

> Date: Thu, 4 May 2023 16:59:31 +1200 (NZST)
> From: John Harper <john.harper@vuw.ac.nz>
> To: jvdelisle at gcc dot gnu.org <gcc-bugzilla@gcc.gnu.org>
> Subject: Re: [Bug libfortran/109662] bad namelist input but gfortran accepted
>     it
> 
> OK by me but I'm not in charge of gfortran!
>
> On Thu, 4 May 2023, jvdelisle at gcc dot gnu.org wrote:
>
>> Date: Thu, 4 May 2023 03:05:49 +0000
>> From: jvdelisle at gcc dot gnu.org <gcc-bugzilla@gcc.gnu.org>
>> To: John Harper <john.harper@vuw.ac.nz>
>> Subject: [Bug libfortran/109662] bad namelist input but gfortran accepted 
>> it
>> Resent-Date: Thu, 4 May 2023 15:05:59 +1200 (NZST)
>> Resent-From: <john.harper@vuw.ac.nz>
>> 
>> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109662
>> 
>> --- Comment #5 from Jerry DeLisle <jvdelisle at gcc dot gnu.org> ---
>> Is this acceptable:
>> 
>> $ ./a.out
>> Compiler version = GCC version 14.0.0 20230424 (experimental)
>> Compiler options = -mtune=generic -march=x86-64 -Wpedantic
>> -fpre-include=/usr/include/finclude/math-vector-fortran.h
>> At line 9 of file pr109662.f90
>> Fortran runtime error: Comma after namelist name not allowed
>> 
>> Should I allow it with -std=legacy?
>> 
>> -- 
>> You are receiving this mail because:
>> You reported the bug.
>> 
>
>
> -- John Harper, School of Mathematics and Statistics
> Victoria Univ. of Wellington, PO Box 600, Wellington 6140, New Zealand.
> e-mail john.harper@vuw.ac.nz phone +64(0) 4 463 5276
>


-- John Harper, School of Mathematics and Statistics
Victoria Univ. of Wellington, PO Box 600, Wellington 6140, New Zealand.
e-mail john.harper@vuw.ac.nz phone +64(0) 4 463 5276

^ permalink raw reply	[flat|nested] 23+ messages in thread

* [Bug libfortran/109662] bad namelist input but gfortran accepted it
  2023-04-28  8:20 [Bug fortran/109662] New: bad namelist input but gfortran accepted it john.harper at vuw dot ac.nz
                   ` (6 preceding siblings ...)
  2023-05-04  6:00 ` john.harper at vuw dot ac.nz
@ 2023-05-05  2:44 ` jvdelisle at gcc dot gnu.org
  2023-05-06 14:23 ` cvs-commit at gcc dot gnu.org
                   ` (13 subsequent siblings)
  21 siblings, 0 replies; 23+ messages in thread
From: jvdelisle at gcc dot gnu.org @ 2023-05-05  2:44 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109662

--- Comment #8 from Jerry DeLisle <jvdelisle at gcc dot gnu.org> ---
A side comment. We have a runtime function called "notify_std". Every time I
try to use it I struggle as it is not intuitively obvious how it works. We
ought to provide some better documentation on using it in the gfortran wiki.

^ permalink raw reply	[flat|nested] 23+ messages in thread

* [Bug libfortran/109662] bad namelist input but gfortran accepted it
  2023-04-28  8:20 [Bug fortran/109662] New: bad namelist input but gfortran accepted it john.harper at vuw dot ac.nz
                   ` (7 preceding siblings ...)
  2023-05-05  2:44 ` jvdelisle at gcc dot gnu.org
@ 2023-05-06 14:23 ` cvs-commit at gcc dot gnu.org
  2023-05-06 14:45 ` jvdelisle at gcc dot gnu.org
                   ` (12 subsequent siblings)
  21 siblings, 0 replies; 23+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-05-06 14:23 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109662

--- Comment #9 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jerry DeLisle <jvdelisle@gcc.gnu.org>:

https://gcc.gnu.org/g:96d699196285858df5d1484b4443cf849908662f

commit r14-541-g96d699196285858df5d1484b4443cf849908662f
Author: Jerry DeLisle <jvdelisle@gcc.gnu.org>
Date:   Fri May 5 20:12:25 2023 -0700

    Fortran: Namelist read with invalid input accepted.

            PR fortran/109662

    libgfortran/ChangeLog:

            * io/list_read.c: Add a check for a comma after a namelist
            name in read input. Issue a runtime error message.

    gcc/testsuite/ChangeLog:

            * gfortran.dg/pr109662.f90: New test.

^ permalink raw reply	[flat|nested] 23+ messages in thread

* [Bug libfortran/109662] bad namelist input but gfortran accepted it
  2023-04-28  8:20 [Bug fortran/109662] New: bad namelist input but gfortran accepted it john.harper at vuw dot ac.nz
                   ` (8 preceding siblings ...)
  2023-05-06 14:23 ` cvs-commit at gcc dot gnu.org
@ 2023-05-06 14:45 ` jvdelisle at gcc dot gnu.org
  2023-05-07  2:15 ` john.harper at vuw dot ac.nz
                   ` (11 subsequent siblings)
  21 siblings, 0 replies; 23+ messages in thread
From: jvdelisle at gcc dot gnu.org @ 2023-05-06 14:45 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109662

Jerry DeLisle <jvdelisle at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--- Comment #10 from Jerry DeLisle <jvdelisle at gcc dot gnu.org> ---
This is fixed on trunk.

To clarify, the comma is accepted as before with -std=legacy and -std=gnu.

It is rejected with -std=f95, -std=2003, and -std=f2018.

Cheers!

^ permalink raw reply	[flat|nested] 23+ messages in thread

* [Bug libfortran/109662] bad namelist input but gfortran accepted it
  2023-04-28  8:20 [Bug fortran/109662] New: bad namelist input but gfortran accepted it john.harper at vuw dot ac.nz
                   ` (9 preceding siblings ...)
  2023-05-06 14:45 ` jvdelisle at gcc dot gnu.org
@ 2023-05-07  2:15 ` john.harper at vuw dot ac.nz
  2023-05-07 18:14 ` jvdelisle at gcc dot gnu.org
                   ` (10 subsequent siblings)
  21 siblings, 0 replies; 23+ messages in thread
From: john.harper at vuw dot ac.nz @ 2023-05-07  2:15 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109662

--- Comment #11 from john.harper at vuw dot ac.nz ---
What about std=2008 ?

On Sat, 6 May 2023, jvdelisle at gcc dot gnu.org wrote:

> Date: Sat, 6 May 2023 14:45:39 +0000
> From: jvdelisle at gcc dot gnu.org <gcc-bugzilla@gcc.gnu.org>
> To: John Harper <john.harper@vuw.ac.nz>
> Subject: [Bug libfortran/109662] bad namelist input but gfortran accepted it
> Resent-Date: Sun, 7 May 2023 02:45:51 +1200 (NZST)
> Resent-From: <john.harper@vuw.ac.nz>
> 
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109662
>
> Jerry DeLisle <jvdelisle at gcc dot gnu.org> changed:
>
>           What    |Removed                     |Added
> ----------------------------------------------------------------------------
>             Status|NEW                         |RESOLVED
>         Resolution|---                         |FIXED
>
> --- Comment #10 from Jerry DeLisle <jvdelisle at gcc dot gnu.org> ---
> This is fixed on trunk.
>
> To clarify, the comma is accepted as before with -std=legacy and -std=gnu.
>
> It is rejected with -std=f95, -std=2003, and -std=f2018.
>
> Cheers!
>
> -- 
> You are receiving this mail because:
> You reported the bug.
>


-- John Harper, School of Mathematics and Statistics
Victoria Univ. of Wellington, PO Box 600, Wellington 6140, New Zealand.
e-mail john.harper@vuw.ac.nz phone +64(0) 4 463 5276

^ permalink raw reply	[flat|nested] 23+ messages in thread

* [Bug libfortran/109662] bad namelist input but gfortran accepted it
  2023-04-28  8:20 [Bug fortran/109662] New: bad namelist input but gfortran accepted it john.harper at vuw dot ac.nz
                   ` (10 preceding siblings ...)
  2023-05-07  2:15 ` john.harper at vuw dot ac.nz
@ 2023-05-07 18:14 ` jvdelisle at gcc dot gnu.org
  2023-05-07 18:35 ` jvdelisle at gcc dot gnu.org
                   ` (9 subsequent siblings)
  21 siblings, 0 replies; 23+ messages in thread
From: jvdelisle at gcc dot gnu.org @ 2023-05-07 18:14 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109662

--- Comment #12 from Jerry DeLisle <jvdelisle at gcc dot gnu.org> ---
A additional adjustment to reject the semi-colon always.

diff --git a/libgfortran/io/list_read.c b/libgfortran/io/list_read.c
index 78bfd9e8787..db3330060ce 100644
--- a/libgfortran/io/list_read.c
+++ b/libgfortran/io/list_read.c
@@ -3598,9 +3598,9 @@ find_nml_name:

   /* A trailing space is required, we allow a comma with std=gnu.  */
   c = next_char (dtp);
-  if (c == ',' && !(compile_options.allow_std & GFC_STD_GNU))
+  if ((c == ',' && !(compile_options.allow_std & GFC_STD_GNU)) || c == ';')
     generate_error (&dtp->common, LIBERROR_READ_VALUE,
-                   "Comma after namelist name not allowed");
+                   "Non blank after namelist name not allowed");

   if (!is_separator(c) && c != '!')
     {

^ permalink raw reply	[flat|nested] 23+ messages in thread

* [Bug libfortran/109662] bad namelist input but gfortran accepted it
  2023-04-28  8:20 [Bug fortran/109662] New: bad namelist input but gfortran accepted it john.harper at vuw dot ac.nz
                   ` (11 preceding siblings ...)
  2023-05-07 18:14 ` jvdelisle at gcc dot gnu.org
@ 2023-05-07 18:35 ` jvdelisle at gcc dot gnu.org
  2023-05-07 21:46 ` john.harper at vuw dot ac.nz
                   ` (8 subsequent siblings)
  21 siblings, 0 replies; 23+ messages in thread
From: jvdelisle at gcc dot gnu.org @ 2023-05-07 18:35 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109662

--- Comment #13 from Jerry DeLisle <jvdelisle at gcc dot gnu.org> ---
(In reply to Jerry DeLisle from comment #12)

That recent patch regression tests fine. I should mention, there is one of our
original test cases in gfortran.dg that does use a comma. We definitely have
see the comma used, but I have never seen a semi-colon.  I think because it is
a newer feature allowing semicoln separators between FORTRAN statements on a
single line. (?)

Regardless, I am ready to push this out to trunk.

^ permalink raw reply	[flat|nested] 23+ messages in thread

* [Bug libfortran/109662] bad namelist input but gfortran accepted it
  2023-04-28  8:20 [Bug fortran/109662] New: bad namelist input but gfortran accepted it john.harper at vuw dot ac.nz
                   ` (12 preceding siblings ...)
  2023-05-07 18:35 ` jvdelisle at gcc dot gnu.org
@ 2023-05-07 21:46 ` john.harper at vuw dot ac.nz
  2023-05-07 21:55 ` john.harper at vuw dot ac.nz
                   ` (7 subsequent siblings)
  21 siblings, 0 replies; 23+ messages in thread
From: john.harper at vuw dot ac.nz @ 2023-05-07 21:46 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109662

--- Comment #14 from john.harper at vuw dot ac.nz ---
Rejecting a semicolon after the namelist name even if the decimal edit 
mode is COMMA makes sense because COMMA was first allowed in f2003, 
provided that semicolons in namelist were a pre-f2003 legacy possibility.

John H

On Sun, 7 May 2023, jvdelisle at gcc dot gnu.org wrote:

> Date: Sun, 7 May 2023 18:14:23 +0000
> From: jvdelisle at gcc dot gnu.org <gcc-bugzilla@gcc.gnu.org>
> To: John Harper <john.harper@vuw.ac.nz>
> Subject: [Bug libfortran/109662] bad namelist input but gfortran accepted it
> Resent-Date: Mon, 8 May 2023 06:14:37 +1200 (NZST)
> Resent-From: <john.harper@vuw.ac.nz>
> 
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109662
>
> --- Comment #12 from Jerry DeLisle <jvdelisle at gcc dot gnu.org> ---
> A additional adjustment to reject the semi-colon always.
>
> diff --git a/libgfortran/io/list_read.c b/libgfortran/io/list_read.c
> index 78bfd9e8787..db3330060ce 100644
> --- a/libgfortran/io/list_read.c
> +++ b/libgfortran/io/list_read.c
> @@ -3598,9 +3598,9 @@ find_nml_name:
>
>   /* A trailing space is required, we allow a comma with std=gnu.  */
>   c = next_char (dtp);
> -  if (c == ',' && !(compile_options.allow_std & GFC_STD_GNU))
> +  if ((c == ',' && !(compile_options.allow_std & GFC_STD_GNU)) || c == ';')
>     generate_error (&dtp->common, LIBERROR_READ_VALUE,
> -                   "Comma after namelist name not allowed");
> +                   "Non blank after namelist name not allowed");
>
>   if (!is_separator(c) && c != '!')
>     {
>
> -- 
> You are receiving this mail because:
> You reported the bug.
>


-- John Harper, School of Mathematics and Statistics
Victoria Univ. of Wellington, PO Box 600, Wellington 6140, New Zealand.
e-mail john.harper@vuw.ac.nz phone +64(0) 4 463 5276

^ permalink raw reply	[flat|nested] 23+ messages in thread

* [Bug libfortran/109662] bad namelist input but gfortran accepted it
  2023-04-28  8:20 [Bug fortran/109662] New: bad namelist input but gfortran accepted it john.harper at vuw dot ac.nz
                   ` (13 preceding siblings ...)
  2023-05-07 21:46 ` john.harper at vuw dot ac.nz
@ 2023-05-07 21:55 ` john.harper at vuw dot ac.nz
  2023-05-07 22:10 ` john.harper at vuw dot ac.nz
                   ` (6 subsequent siblings)
  21 siblings, 0 replies; 23+ messages in thread
From: john.harper at vuw dot ac.nz @ 2023-05-07 21:55 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109662

--- Comment #15 from john.harper at vuw dot ac.nz ---
Sorry: what I should have said was that

If and only if a comma after a namelist name was a pre-2003 possibility 
for gfortran then it makes sense to reject a semicolon there when the 
decimal edit mode is COMMA, which first got into the standard with f2003.

John H

On Sun, 7 May 2023, john.harper at vuw dot ac.nz wrote:

> Date: Sun, 7 May 2023 21:46:33 +0000
> From: john.harper at vuw dot ac.nz <gcc-bugzilla@gcc.gnu.org>
> To: John Harper <john.harper@vuw.ac.nz>
> Subject: [Bug libfortran/109662] bad namelist input but gfortran accepted it
> Resent-Date: Mon, 8 May 2023 09:46:44 +1200 (NZST)
> Resent-From: <john.harper@vuw.ac.nz>
> 
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109662
>
> --- Comment #14 from john.harper at vuw dot ac.nz ---
> Rejecting a semicolon after the namelist name even if the decimal edit
> mode is COMMA makes sense because COMMA was first allowed in f2003,
> provided that semicolons in namelist were a pre-f2003 legacy possibility.
>
> John H
>
> On Sun, 7 May 2023, jvdelisle at gcc dot gnu.org wrote:
>
>> Date: Sun, 7 May 2023 18:14:23 +0000
>> From: jvdelisle at gcc dot gnu.org <gcc-bugzilla@gcc.gnu.org>
>> To: John Harper <john.harper@vuw.ac.nz>
>> Subject: [Bug libfortran/109662] bad namelist input but gfortran accepted it
>> Resent-Date: Mon, 8 May 2023 06:14:37 +1200 (NZST)
>> Resent-From: <john.harper@vuw.ac.nz>
>>
>> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109662
>>
>> --- Comment #12 from Jerry DeLisle <jvdelisle at gcc dot gnu.org> ---
>> A additional adjustment to reject the semi-colon always.
>>
>> diff --git a/libgfortran/io/list_read.c b/libgfortran/io/list_read.c
>> index 78bfd9e8787..db3330060ce 100644
>> --- a/libgfortran/io/list_read.c
>> +++ b/libgfortran/io/list_read.c
>> @@ -3598,9 +3598,9 @@ find_nml_name:
>>
>>   /* A trailing space is required, we allow a comma with std=gnu.  */
>>   c = next_char (dtp);
>> -  if (c == ',' && !(compile_options.allow_std & GFC_STD_GNU))
>> +  if ((c == ',' && !(compile_options.allow_std & GFC_STD_GNU)) || c == ';')
>>     generate_error (&dtp->common, LIBERROR_READ_VALUE,
>> -                   "Comma after namelist name not allowed");
>> +                   "Non blank after namelist name not allowed");
>>
>>   if (!is_separator(c) && c != '!')
>>     {
>>
>> --
>> You are receiving this mail because:
>> You reported the bug.
>>
>
>
> -- John Harper, School of Mathematics and Statistics
> Victoria Univ. of Wellington, PO Box 600, Wellington 6140, New Zealand.
> e-mail john.harper@vuw.ac.nz phone +64(0) 4 463 5276
>
> -- 
> You are receiving this mail because:
> You reported the bug.
>


-- John Harper, School of Mathematics and Statistics
Victoria Univ. of Wellington, PO Box 600, Wellington 6140, New Zealand.
e-mail john.harper@vuw.ac.nz phone +64(0) 4 463 5276

^ permalink raw reply	[flat|nested] 23+ messages in thread

* [Bug libfortran/109662] bad namelist input but gfortran accepted it
  2023-04-28  8:20 [Bug fortran/109662] New: bad namelist input but gfortran accepted it john.harper at vuw dot ac.nz
                   ` (14 preceding siblings ...)
  2023-05-07 21:55 ` john.harper at vuw dot ac.nz
@ 2023-05-07 22:10 ` john.harper at vuw dot ac.nz
  2023-05-08  2:03 ` cvs-commit at gcc dot gnu.org
                   ` (5 subsequent siblings)
  21 siblings, 0 replies; 23+ messages in thread
From: john.harper at vuw dot ac.nz @ 2023-05-07 22:10 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109662

--- Comment #16 from john.harper at vuw dot ac.nz ---
Saw this only after my previous 2 replies, A semicolon in a namelist is 
not a separator between Fortran statements, but it takes the place of a 
comma between values when decimal='COMMA' in an open, read or write 
statement according to f2003 10.9 and 10.10, and 9.5.1 C928 says decimal= 
and nml= may both appear in a data transfer statement.

John

On Sun, 7 May 2023, jvdelisle at gcc dot gnu.org wrote:

> Date: Sun, 7 May 2023 18:35:46 +0000
> From: jvdelisle at gcc dot gnu.org <gcc-bugzilla@gcc.gnu.org>
> To: John Harper <john.harper@vuw.ac.nz>
> Subject: [Bug libfortran/109662] bad namelist input but gfortran accepted it
> Resent-Date: Mon, 8 May 2023 06:36:00 +1200 (NZST)
> Resent-From: <john.harper@vuw.ac.nz>
> 
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109662
>
> --- Comment #13 from Jerry DeLisle <jvdelisle at gcc dot gnu.org> ---
> (In reply to Jerry DeLisle from comment #12)
>
> That recent patch regression tests fine. I should mention, there is one of our
> original test cases in gfortran.dg that does use a comma. We definitely have
> see the comma used, but I have never seen a semi-colon.  I think because it is
> a newer feature allowing semicoln separators between FORTRAN statements on a
> single line. (?)
>
> Regardless, I am ready to push this out to trunk.
>
> -- 
> You are receiving this mail because:
> You reported the bug.
>


-- John Harper, School of Mathematics and Statistics
Victoria Univ. of Wellington, PO Box 600, Wellington 6140, New Zealand.
e-mail john.harper@vuw.ac.nz phone +64(0) 4 463 5276

^ permalink raw reply	[flat|nested] 23+ messages in thread

* [Bug libfortran/109662] bad namelist input but gfortran accepted it
  2023-04-28  8:20 [Bug fortran/109662] New: bad namelist input but gfortran accepted it john.harper at vuw dot ac.nz
                   ` (15 preceding siblings ...)
  2023-05-07 22:10 ` john.harper at vuw dot ac.nz
@ 2023-05-08  2:03 ` cvs-commit at gcc dot gnu.org
  2023-05-09  0:41 ` jvdelisle at gcc dot gnu.org
                   ` (4 subsequent siblings)
  21 siblings, 0 replies; 23+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-05-08  2:03 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109662

--- Comment #17 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jerry DeLisle <jvdelisle@gcc.gnu.org>:

https://gcc.gnu.org/g:d46b3db4bd016a3eccfb933c81c7a9d87c0ad403

commit r14-566-gd46b3db4bd016a3eccfb933c81c7a9d87c0ad403
Author: Jerry DeLisle <jvdelisle@gcc.gnu.org>
Date:   Sun May 7 18:54:55 2023 -0700

    Fortran: Reject semicolon after namelist name.

            PR fortran/109662

    libgfortran/ChangeLog:

            * io/list_read.c: Add check for a semicolon after a namelist
            name in read input. Issue a runtime error message.

    gcc/testsuite/ChangeLog:

            * gfortran.dg/pr109662-a.f90: New test.

^ permalink raw reply	[flat|nested] 23+ messages in thread

* [Bug libfortran/109662] bad namelist input but gfortran accepted it
  2023-04-28  8:20 [Bug fortran/109662] New: bad namelist input but gfortran accepted it john.harper at vuw dot ac.nz
                   ` (16 preceding siblings ...)
  2023-05-08  2:03 ` cvs-commit at gcc dot gnu.org
@ 2023-05-09  0:41 ` jvdelisle at gcc dot gnu.org
  2023-05-09  1:15 ` jvdelisle at gcc dot gnu.org
                   ` (3 subsequent siblings)
  21 siblings, 0 replies; 23+ messages in thread
From: jvdelisle at gcc dot gnu.org @ 2023-05-09  0:41 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109662

Jerry DeLisle <jvdelisle at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|FIXED                       |---

--- Comment #18 from Jerry DeLisle <jvdelisle at gcc dot gnu.org> ---
Reopening to address other potential issues.

^ permalink raw reply	[flat|nested] 23+ messages in thread

* [Bug libfortran/109662] bad namelist input but gfortran accepted it
  2023-04-28  8:20 [Bug fortran/109662] New: bad namelist input but gfortran accepted it john.harper at vuw dot ac.nz
                   ` (17 preceding siblings ...)
  2023-05-09  0:41 ` jvdelisle at gcc dot gnu.org
@ 2023-05-09  1:15 ` jvdelisle at gcc dot gnu.org
  2023-05-12 20:41 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  21 siblings, 0 replies; 23+ messages in thread
From: jvdelisle at gcc dot gnu.org @ 2023-05-09  1:15 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109662

--- Comment #19 from Jerry DeLisle <jvdelisle at gcc dot gnu.org> ---
Created attachment 55024
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=55024&action=edit
An enhanced test case

This test case from Herald illustrates a variety of combinations.

Giving:

$ gfc -std=f2018 pr109662-xx.f90 
$ ./a.out 
 Compiler version = GCC version 14.0.0 20230506 (experimental)
 1-line:       > <         759           0
 2-line/left:  > <         759           0
 2-line/right: > <         759           0
 1-line:       >!<          -1          -1
 2-line/left:  >!<          -1           0
 2-line/right: >!<         759           0
 1-line:       >/<          -1           0
 2-line/left:  >/<          -1           0
 2-line/right: >/<          -1           0
 1-line:       >,<         759        5010
 2-line/left:  >,<         759        5010
 2-line/right: >,<         759        5010
 1-line:       >;<         759        5010
 2-line/left:  >;<         759        5010
 2-line/right: >;<         759        5010
 1-line:       tab         759           0
 2-line/left:  tab         759           0
 2-line/right: tab         759           0
 1-line:       lf         759           0
 2-line/left:  lf         759           0
 2-line/right: lf         759           0
 1-line:       ret         759           0
 2-line/left:  ret         759           0
 2-line/right: ret         759           0

^ permalink raw reply	[flat|nested] 23+ messages in thread

* [Bug libfortran/109662] bad namelist input but gfortran accepted it
  2023-04-28  8:20 [Bug fortran/109662] New: bad namelist input but gfortran accepted it john.harper at vuw dot ac.nz
                   ` (18 preceding siblings ...)
  2023-05-09  1:15 ` jvdelisle at gcc dot gnu.org
@ 2023-05-12 20:41 ` cvs-commit at gcc dot gnu.org
  2023-05-12 20:41 ` cvs-commit at gcc dot gnu.org
  2023-08-25  1:03 ` jvdelisle at gcc dot gnu.org
  21 siblings, 0 replies; 23+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-05-12 20:41 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109662

--- Comment #20 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jerry DeLisle <jvdelisle@gcc.gnu.org>:

https://gcc.gnu.org/g:cf3b032b8fb681516ccacbe3689f1cad43a1773a

commit r14-801-gcf3b032b8fb681516ccacbe3689f1cad43a1773a
Author: Jerry DeLisle <jvdelisle@gcc.gnu.org>
Date:   Fri May 12 12:23:00 2023 -0700

    Fortran: Initialize last_char for internal units.

            PR fortran/109662

    libgfortran/ChangeLog:

            * io/unit.c (set_internal_unit): Set the internal unit
            last_char to zero so that previous EOF characters do not
            influence the next read.

^ permalink raw reply	[flat|nested] 23+ messages in thread

* [Bug libfortran/109662] bad namelist input but gfortran accepted it
  2023-04-28  8:20 [Bug fortran/109662] New: bad namelist input but gfortran accepted it john.harper at vuw dot ac.nz
                   ` (19 preceding siblings ...)
  2023-05-12 20:41 ` cvs-commit at gcc dot gnu.org
@ 2023-05-12 20:41 ` cvs-commit at gcc dot gnu.org
  2023-08-25  1:03 ` jvdelisle at gcc dot gnu.org
  21 siblings, 0 replies; 23+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-05-12 20:41 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109662

--- Comment #21 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jerry DeLisle <jvdelisle@gcc.gnu.org>:

https://gcc.gnu.org/g:96cc09dea48b562a0fc93d43fb3b702ac20b89fd

commit r14-802-g96cc09dea48b562a0fc93d43fb3b702ac20b89fd
Author: Jerry DeLisle <jvdelisle@gcc.gnu.org>
Date:   Fri May 12 13:38:25 2023 -0700

    Fortran: Revise a namelist test case.

            PR fortran/109662

    gcc/testsuite/ChangeLog:

            * gfortran.dg/pr109662-a.f90: Add a section to verify that
            a short namelist read does not modify the variable.

^ permalink raw reply	[flat|nested] 23+ messages in thread

* [Bug libfortran/109662] bad namelist input but gfortran accepted it
  2023-04-28  8:20 [Bug fortran/109662] New: bad namelist input but gfortran accepted it john.harper at vuw dot ac.nz
                   ` (20 preceding siblings ...)
  2023-05-12 20:41 ` cvs-commit at gcc dot gnu.org
@ 2023-08-25  1:03 ` jvdelisle at gcc dot gnu.org
  21 siblings, 0 replies; 23+ messages in thread
From: jvdelisle at gcc dot gnu.org @ 2023-08-25  1:03 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109662

Jerry DeLisle <jvdelisle at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|REOPENED                    |RESOLVED

--- Comment #22 from Jerry DeLisle <jvdelisle at gcc dot gnu.org> ---
Closing.

^ permalink raw reply	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2023-08-25  1:03 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-28  8:20 [Bug fortran/109662] New: bad namelist input but gfortran accepted it john.harper at vuw dot ac.nz
2023-04-28 21:20 ` [Bug libfortran/109662] " anlauf at gcc dot gnu.org
2023-04-30 22:40 ` kargl at gcc dot gnu.org
2023-05-01  0:37 ` jvdelisle at gcc dot gnu.org
2023-05-01  3:05 ` jvdelisle at gcc dot gnu.org
2023-05-04  3:05 ` jvdelisle at gcc dot gnu.org
2023-05-04  4:59 ` john.harper at vuw dot ac.nz
2023-05-04  6:00 ` john.harper at vuw dot ac.nz
2023-05-05  2:44 ` jvdelisle at gcc dot gnu.org
2023-05-06 14:23 ` cvs-commit at gcc dot gnu.org
2023-05-06 14:45 ` jvdelisle at gcc dot gnu.org
2023-05-07  2:15 ` john.harper at vuw dot ac.nz
2023-05-07 18:14 ` jvdelisle at gcc dot gnu.org
2023-05-07 18:35 ` jvdelisle at gcc dot gnu.org
2023-05-07 21:46 ` john.harper at vuw dot ac.nz
2023-05-07 21:55 ` john.harper at vuw dot ac.nz
2023-05-07 22:10 ` john.harper at vuw dot ac.nz
2023-05-08  2:03 ` cvs-commit at gcc dot gnu.org
2023-05-09  0:41 ` jvdelisle at gcc dot gnu.org
2023-05-09  1:15 ` jvdelisle at gcc dot gnu.org
2023-05-12 20:41 ` cvs-commit at gcc dot gnu.org
2023-05-12 20:41 ` cvs-commit at gcc dot gnu.org
2023-08-25  1:03 ` jvdelisle at gcc dot gnu.org

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).