public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/109897] New: Incorrect bad namelist object reported in error message when bad data appears after a valid array component
@ 2023-05-17 19:46 W.H.Ball at bham dot ac.uk
  2023-05-17 20:28 ` [Bug libfortran/109897] " anlauf at gcc dot gnu.org
  2023-05-17 20:35 ` W.H.Ball at bham dot ac.uk
  0 siblings, 2 replies; 3+ messages in thread
From: W.H.Ball at bham dot ac.uk @ 2023-05-17 19:46 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 109897
           Summary: Incorrect bad namelist object reported in error
                    message when bad data appears after a valid array
                    component
           Product: gcc
           Version: og12 (devel/omp/gcc-12)
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: W.H.Ball at bham dot ac.uk
  Target Milestone: ---

Hi,

A user on a Fortran project was confused by the error message they received
when they provided incorrect parameters in a Fortran namelist. To reproduce, I
created this small program:


$ cat bna.f90
program bna

  implicit none

  integer :: iounit, array(3)

  namelist /test/ array

  open(newunit=iounit, file='test.nml', status='old')
  read(iounit, nml=test)
  close(iounit)

end program bna


with this associated namlist `test.nml`:

$ cat test.nml
&test
  array(1) = 2
  bad_namelist = 3
/


Compiling (with default options) and running leads to this error message:


$ ./bna.x
At line 10 of file bna.f90
Fortran runtime error: Bad data for namelist object array
<...backtrace...>


This also happens if I set the value for `array(2)` instead of `array(1)` but
works correctly if I set the value for `array(3)`, which is conspicuously the
last element:


$ cat test.nml
&test
  array(3) = 2
  bad_namelist = 3
/
$ ./bna.x
At line 10 of file bna.f90
Fortran runtime error: Cannot match namelist object name bad_namelist


This isn't a major issue but it would help if, in the first case, the error
message would correctly identify `bad_namelist` as being the invalid parameter.

I'm personally using gcc 12.3.1 on Fedora 37 but it was reported from and
separately reproduced on other systems (whose details I don't know). I searched
the list of known bugs for "namelist" in the Fortran component but didn't come
across anything that looked specifically like this bug.

Cheers,
Warrick

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

* [Bug libfortran/109897] Incorrect bad namelist object reported in error message when bad data appears after a valid array component
  2023-05-17 19:46 [Bug fortran/109897] New: Incorrect bad namelist object reported in error message when bad data appears after a valid array component W.H.Ball at bham dot ac.uk
@ 2023-05-17 20:28 ` anlauf at gcc dot gnu.org
  2023-05-17 20:35 ` W.H.Ball at bham dot ac.uk
  1 sibling, 0 replies; 3+ messages in thread
From: anlauf at gcc dot gnu.org @ 2023-05-17 20:28 UTC (permalink / raw)
  To: gcc-bugs

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

anlauf at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|fortran                     |libfortran
           Priority|P3                          |P5
   Last reconfirmed|                            |2023-5-17
           Severity|normal                      |enhancement

--- Comment #1 from anlauf at gcc dot gnu.org ---
I get a nicer error message when I specify the compiler flag -std=f2018
on the command line:

Fortran runtime error: Cannot match namelist object name bad_namelist

So there might have been some attempt so support legacy stuff so that
you don't get the best user experience by default.

Can you confirm this?

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

* [Bug libfortran/109897] Incorrect bad namelist object reported in error message when bad data appears after a valid array component
  2023-05-17 19:46 [Bug fortran/109897] New: Incorrect bad namelist object reported in error message when bad data appears after a valid array component W.H.Ball at bham dot ac.uk
  2023-05-17 20:28 ` [Bug libfortran/109897] " anlauf at gcc dot gnu.org
@ 2023-05-17 20:35 ` W.H.Ball at bham dot ac.uk
  1 sibling, 0 replies; 3+ messages in thread
From: W.H.Ball at bham dot ac.uk @ 2023-05-17 20:35 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from W.H.Ball at bham dot ac.uk ---
> Can you confirm this?

Yes, I get the same. I also get a nicer error message with -std=f2008.

Thanks for finding this, since that's already a potential workaround I can
investigate in the code that prompted this.

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

end of thread, other threads:[~2023-05-17 20:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-17 19:46 [Bug fortran/109897] New: Incorrect bad namelist object reported in error message when bad data appears after a valid array component W.H.Ball at bham dot ac.uk
2023-05-17 20:28 ` [Bug libfortran/109897] " anlauf at gcc dot gnu.org
2023-05-17 20:35 ` W.H.Ball at bham dot ac.uk

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