https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69456
Bug ID: 69456 Summary: Namelist value with trailing sign is ignored without error Product: gcc Version: 6.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: jschwab at gmail dot com Target Milestone: --- I recently encountered the following unexpected behavior in 4.9.4. I built trunk on 20160123 (r232765) and confirmed this behavior still exists. If a real value in a namelist has a trailing sign, its value is ignored and the value remains unmodified. I expected this to lead to a runtime error when reading the namelist. I read the code for the function parse_real in libgfortran/io/list_read.c and this behavior appears to exist because the value '1+1' is permitted as a shorthand for '1e+1'. This was also surprising to me. I read the Fortran 2008 specification. I had difficulty fully understanding it, but I failed to find a place where it said that exponent-letter can be legally omitted. A look at the list of gfortran vendor extensions as well as a web search also failed to provide additional information. A sample program (adapted from pr56743) demonstrating this behavior is below: implicit none real :: r1 = -1 real :: r2 = -1 real :: r3 = -1 real :: r4 = -1 namelist /nml/ r1, r2, r3, r4 write (*, nml=nml) open (99, file='nml.dat', status="replace") write(99,*) "&nml" write(99,*) " r1=1+" ! BUG: wrong result: Unmodified, no error write(99,*) " r2=1-" ! BUG: wrong result: Unmodified, no error write(99,*) " r3=1+1" ! Treated as 1e+1?! write(99,*) " r4=1-1" ! Treated as 1e-1?! write(99,*) "/" rewind(99) read (99, nml=nml) write (*, nml=nml) close (99, status="delete") end The output of this program is &NML R1= -1.00000000 , R2= -1.00000000 , R3= -1.00000000 , R4= -1.00000000 , / &NML R1= -1.00000000 , R2= -1.00000000 , R3= 10.0000000 , R4= 0.100000001 , /