[fpc-devel] Looking for some general clarification on how exactly revision #43175 "fixes" bugtracker issue #0036139

Ben Grasset operator97 at gmail.com
Sun Oct 13 01:54:47 CEST 2019


I guess this doesn't matter too much in the grand scheme of things, but I'm
somewhat confused by it, so I thought I'd ask.

Specifically, the reporter of that issue, calling themselves "Alexander",
used the following program as an "example" of what they called "too
aggressive optimization":

program test:
var v:longword;
begin
   if v=2 then while true do ;
end.

To me, that just shows a while loop that will very obviously be exited
immediately in all cases, because "v" is very obviously *not* equal to 2.
Yet they used a (tiny) snippet of assembler from this and deemed it
"incorrect", without making any attempt to clarify what they meant.

Generally speaking, I would expect any compiler that is *capable* of
realizing that the while loop has zero chance of *ever being entered at
all* in the first place to remove the loop from its final codegen entirely,
because there's no logical reason for it to be there.

As far as I can tell, FPC is not (yet) such a compiler. That said, that's
not really such a big deal, because it obviously still immediately
determines that it shouldn't even *start* the loop and proceeds as normal.

So yeah: basically, the bottom line is I don't quite see what Jonas
determined to actually *be* a bug on display in that particular issue, at
all. To me it demonstrated nothing but a program that blatantly did exactly
what it obviously would do.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20191012/ceebe6b0/attachment.html>


More information about the fpc-devel mailing list