[fpc-devel]Bug with -O2 optimisation in 1.0.4

Bruce Merry bmerry at alfonzo.smuts.uct.ac.za
Sun Apr 28 13:02:03 CEST 2002


Hello

During a contest I discovered that these is a bug in the -O2
optimisation. Firstly let me state that I've actually looked at the
assembly code; it's not a problem with uninitialised variables or
something.

I've attached a code snippet, which is a heavy reduced version of the
program that still displays the bug. Running the program w/o
optimisations prints out the answer '1', as does -O1. However -O2
causes a different answer to be output. Looking at the generated
assembly (from ppc386 -O2 -a -gl demo.pas) shows that the code
generated for line 19 is incorrect: the first instruction is imull
$24,%edx. This instruction also appears as part of the code for line 18
(to compute an offset from an array index, where $24 is related to the
size of the array elements) and seems to have been mysteriously copied
into line 19.

I'm using FreePascal 1.0.4 on Debian GNU/Linux from the package
fp-compiler version 1.0.4-2. The kernel is 2.4.18. I've also been able
to exhibit the problem with the GO32V2 version running on top of Win95
on another machine.

I'm not a member of the list, so please cc any queries to this email
address.

If anyone thinks that this might be fixed in a snapshot, I'd be happy
to test this. However I don't have the time for gratuitous testing.

Good luck
Bruce
-- 
/--------------------------------------------------------------------\
| Bruce Merry (Entropy)            | bmerry at smuts . uct . ac . za |
| Proud user of Linux!             | http://www.cs.uct.ac.za/~bmerry |
|                     Q: What is x if x^2=4b^2?                      |
|                       A: To be or not to be.                       |
\--------------------------------------------------------------------/




More information about the fpc-devel mailing list