[net.bugs] PASCAL BUG?

coltoff (10/20/82)

Here is one that is driving us crazy tracking down the problem.
Can someone help us out.

The following PASCAL program

program bug (input,output);
const
    x1 = 200;
    x2 = 200.0;
var
    x: real;
begin
    x := x1;
    write(x:6:3);
    x := x2;
    write(x:6:3);
end.

produces this output

 -56.000 200.000

This is clearly not what I would expect and while it isn't difficult
to work around in the programs I deal with it is still a pain in the
gazabahs. As they say, `Thanks in advance'

Joel Coltoff
lime!burdvax!coltoff

thomas (10/22/82)

Now, I can't say for sure, but it looks as if somebody is storing that
integer constant (200) in a byte (it fits, after all, 200 < 256), but
then treating said byte as a signed quantity (i.e., -56).
=Spencer

mcdaniel (10/23/82)

#R:burdvax:-24100:uiucdcs:8000003:000:132
uiucdcs!mcdaniel    Oct 22 20:04:00 1982

This bug, and its solution, is discussed in net.bugs.4bsd, in a note by 
rabbit!ark. (=Spencer's hypothesis is apparently correct.)

mcdaniel (10/23/82)

#R:burdvax:-24100:uiucdcs:8000005:000:170
uiucdcs!mcdaniel    Oct 22 20:47:00 1982

However, I just noticed "pascal bug fix", in net.unix-wizar, from
lime!burdvax!coltolf, which indicates that the above "fix" causes further
problems. Better read it too.