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