public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "W.H.Ball at bham dot ac.uk" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/109897] New: Incorrect bad namelist object reported in error message when bad data appears after a valid array component
Date: Wed, 17 May 2023 19:46:21 +0000	[thread overview]
Message-ID: <bug-109897-4@http.gcc.gnu.org/bugzilla/> (raw)

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

             reply	other threads:[~2023-05-17 19:46 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-17 19:46 W.H.Ball at bham dot ac.uk [this message]
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

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=bug-109897-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /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).