Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watmath!clyde!rutgers!ames!hc!beta!unm-la!unmvax!charon!geinah!bgoldma From: bgoldma@geinah.UUCP Newsgroups: comp.bugs.4bsd Subject: bug in f77 on 4.3 bsd Message-ID: <928@charon.unm.edu> Date: Thu, 23-Apr-87 18:19:03 EST Article-I.D.: charon.928 Posted: Thu Apr 23 18:19:03 1987 Date-Received: Sat, 25-Apr-87 08:35:22 EST Sender: news@charon.unm.edu Lines: 37 I have found a bug in f77 released with 4.3. When a comparison of a substring delimited by nonevaluated expressions is anded with another the results are not always correct. Here is a sample program illustrating this. The problem is because "(1)" is evaluated differently than "1". By the same token, using a variable such as "j" will work, but using "j+1" will not. It has something to do with when it is evaluated and compiling with the optimizer usually fixes this by cheating. I do not have a fix for this and I do not know exactly what the error is. program bug character*2 atom logical row atom(1:1) = 'H' atom(2:2) = 'H' if(atom((1):(1)).eq.'H') print*,'first true' if (atom((2):(2)).eq.'H') print*,'second true' C HERE IS THE BUG row = ((atom((1):(1)).eq.'H').and.(atom((2):(2)).eq.'H')) print*,'first and second is ',row C The problem the f77 has is evaluating an integer expression used C as substring delimiters when in a boolean and the boolean is C only temporary. This is not the case if the integer is a constant C as can be seen by the example below. C HERE IS THE BUG C HERE IS THE CORRECT OUTPUT row = ((atom(1:1).eq.'H').and.(atom(2:2).eq.'H')) print*,'first and second is ',row C HERE IS THE CORRECT OUTPUT end BILL Goldman