hirchert@uxe.cso.uiuc.edu.UUCP (09/18/87)
/* Written 12:58 am Sep 17, 1987 by lagache@violet.berkeley.edu in uxe.cso.uiuc.edu:comp.lang.fortran */ /* ---------- ""Interesting" error interpretation" ---------- */ ... PROGRAM PRACT REAL NUM1,NUM2,SUM WRITE(*,*) 'Enter two numbers to be added to each other:' READ(*,*) NUM1, NUM2 SUM = NUM1 + NUM2 WRITE(*,*) WRITE(*,*) 'The sum of the two numbers is : ',SUM STOP END %f77 practice.f practice.f: MAIN pract: Error on line 4 of practice.f: syntax error Warning on line 9 of practice.f: local variable num2 never used Warning on line 9 of practice.f: local variable read never used ^^^^ ----------------------------------------------> ???? <--------- ... /* End of text from uxe.cso.uiuc.edu:comp.lang.fortran */ I don't know about f77 specifically, but a number of Fortran processors make an initial scan of a statement to remove blanks and determine what kind of statement it is and then do the parse based on that knowledge. Since the erroneous combination of the READ statement and the assignment statement has an equal sign not contained in parentheses, the scan apparently decided that the combined statement was an assignment statement, which made READ the variable being assigned to. It might be better if the compiler discarded symbol table information extracted from statements that don't parse correctly, but this can't really be called a bug. Kurt W. Hirchert National Center for Supercomputing Applications University of Illinois
urjlew@ecsvax.UUCP (09/25/87)
I put the test problem through the FORTRAN compiler on our IBM mainframe. The compiler is something like release 2.0 of version 1.4.1 of the VS FORTRAN compiler. There is a newer version Fortran compiler release 2.2 of version 2.0, but we don't have it here. I could access it at Cornell if there was great curiousity on the net readers part. Anyways I did this just to see if the usually maligned IBM did any better or worse than the highly touted DEC. You will find below the highly censored output of the compile. Note Listing of source with internal statement mubers Error messages in line in the source listing Cross reference listing, which indicates that it also took num2 as undefined. a summarry of the errors in the module listed at the end of the module. The errors messages are still not as brilliant as one might hope for. i.e. not diagnosis of shifted statement. -------------------------------------------------------------- *....*...1.........2.........3.........4.........5.........6..... Status: R ISN 1 PROGRAM PRACT ISN 2 REAL NUM1,NUM2,SUM ISN 3 WRITE(*,*) 'Enter two numbers to be added to each other:' ISN 4 READ(*,*) NUM1, NUM2 SUM = NUM1 + NUM2 ***ERROR 1032(S)*** MISPLACED EQUAL SIGN IN EXPRESSION. IN AN ASSIGNMENT ST NAME OR VARIABLE NAME ONLY. ***ERROR 1417(S)*** AN I/O LIST ITEM IS INVALID. EITHER AN EXPRESSION WAS F WHILE PROCESSING THE ITEM. CHECK THAT THE ITEM STATEMENT FUNCTION NAME, OR AN INTRINSIC FUNCTI ISN 5 WRITE(*,*) ISN 6 WRITE(*,*) 'The sum of the two numbers is : ',SUM ISN 7 STOP ISN 8 END ..... some lines of compiler output deleted ........ LEVEL 1.4.1 (MAY 1985) VS FORTRAN DATE: SEP 23, 1987 TIME: SYMBOL CROSS REFERENCE DICTIONARY NAME MODE TAG DECLARED REFERENCES ______ ____ ______ ________ __________ NUM1 R*4 T 2 4 NUM2 R*4 T 2 UNREFERENCED NUM2M I*4 4 SUM R*4 T 2 6 VARIABLES REFERENCED BUT NOT SET. (* POSSIBLY SET AS ARGUMENT.) SUM ....storage map and more deleted ...... *** VS FORTRAN ERROR MESSAGES *** IFX1032I ARTH 12(S) 4 MISPLACED EQUAL SIGN IN EXPRESSION. IN AN ASSIG SUBSCRIPTED ARRAY NAME OR VARIABLE NAME ONLY. IFX1417I IOLS 12(S) 4 AN I/O LIST ITEM IS INVALID. EITHER AN EXPRESSI FOUND WHILE PROCESSING THE ITEM. CHECK THAT THE STATEMENT FUNCTION NAME, OR AN INTRINSIC FUNCTI *STATISTICS* SOURCE STATEMENTS = 8, PROGRAM SIZE = 562 BYTES, PROGRAM NAME = P *STATISTICS* 2 DIAGNOSTICS GENERATED. HIGHEST SEVERITY CODE IS 12. **PRACT** END OF COMPILATION 1 ****** -------------------------------------------------------- Reply-To: Rostyslaw Jarema Lewyckyj urjlew@ecsvax.UUCP , urjlew@tucc.bitnet or urjlew@tucc.tucc.edu (ARPA,SURA,NSF etc. internet) tel. (919)-962-9107