[Date Prev] [Date Next] [Thread Prev] [Thread Next] Date Index Thread Index Search archive:
Date:Mon Sep 25 17:14:19 2003 
Subject:bug in Pop-11/Poplog back-end compiler ? 
From:A . Sloman 
Volume-ID:1030925.02 

David Young has reported this to me

> I thought I'd let you know about the following Pop-11 bug which
> occurs under 15.52 and SunOS - I don't know about other machines.
>
> This code
>
>     if true then
>         not(true or "anything")
>     else
>         "irrelevant"
>     endif
>
> leaves <true> on the stack, instead of the correct <false>.
>
> I'm fairly sure that the problem is that the call to "not" is
> being optimised incorrectly. The VM code is correct, and if you
> trace (and optionally untrace) "not", the code then works
> correctly. I can't really get any further than this myself.
>
> I can of course work round the problem by changing the logic,
> calling identfn, or assigning the result to a variable rather
> than leaving it on the stack. However, an error in a core
> procedure does seem rather serious. Feel free to pass this on to
> popforum if you wish.


Alas it is also in V15.53 running on a PC with linux.

This (equivalent to David's example, but shorter) is NOT OK
   if true then not(true or 77) else 88 endif =>
   ** <true>

This is NOT OK
   if true then not(66 or 77) else 88 endif =>
   ** 66

This is NOT OK
   if true then true or 77; .not else 88 endif =>
   ** <true>

This is OK
	procedure(); not(true or 77) endprocedure() =>
    ** <false>

This is OK
   if true then true or 77 else 88 endif =>
   ** <true>

This is OK
   if true then 66 or 77 else 88 endif =>
   ** 66

This is OK
   not(if true then true or 77 else 88 endif) =>
   ** <false>

This is OK
   if true then not(false or 77) else 88 endif =>
   ** <false>

This is not OK
   if true then not(false and 77) else 88 endif =>
   ** <false>

This is OK
   not(if true then false and 77 else 88 endif) =>
   ** <true>

This is OK
   if false then 88 else not(true or 77) endif =>
   ** <false>

So it looks like a buggy optimisation is being done when 'not'
is applied to an 'or' expression starting 'true' or an 'and'
expression starting 'false', but only after 'then' and not
after 'else'.

I have no idea what's going on. If anyone wants to investigate it
is probably a bug in one of these files

	$popsrc/vm*

Perhaps in
	$popsrc/vm_plant.p

Maybe some interaction between sysIFSO and sysAND sysOR

Whatever the bug is, it must be very old and it's amazing that it
was never previously discovered/reported, not even by people who
like these optimising constructs....

Aaron