Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2002-04

Bug with -O2 optimisation in 1.0.4

2 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Bruce Merry

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) | | | 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. | \--------------------------------------------------------------------/

Reply by email

Jonas Maebe
to Bruce Merry
Bruce Merry wrote
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.

Thanks for the bug report. This problem was reported a couple of weeks ago by the organizers of the organizers of the contest and has already been fixed. The fix is in both the current snapshots and in the the soon to be release 1.0.6 version.

Jonas

Reply by email