[fpc-devel] Types.IntersectRect(), probably bug or misusage VERY URGENT

Michael Van Canneyt michael at freepascal.org
Tue Oct 26 17:26:45 CEST 2010



On Tue, 26 Oct 2010, Sergei Gorelkin wrote:

> Jonas Maebe пишет:
>
>>> With a little testing, here are two facts:
>>> 1) Delphi 7 also shows this bug.
>>> 2) Windows.IntersectRect() does not show it, allowing 'misuses'.
>>> 
>>> So, whoever wrote the FPC function, must have been trying really hard to 
>>> achieve bug-to-bug compatibility with Delphi... or simply copied their 
>>> buggy code.
>> 
>> Not necessarily. It's probably a consequence of the person not seeing a 
>> reason for first doing everything in a temporary variable and then copying 
>> this temporary variable to the destination. Unless you consciously think 
>> about the fact that const parameters may be passed by reference, it's easy 
>> to make such "mistakes" (although technically, they are not mistakes, but 
>> they do make it easier for people using such a function to make error).
>> 
> Well, maybe. For me, it is rather hard to think about the opposite - that a 
> const may be passed *not* by reference - due to long-term Delphi/Windows 
> experience.
>
> But, after all, Types.IntersectRect and surrounding stuff were introduced and 
> are intended as WinApi replacement, and WinApi IntersectRect() *does* pass 
> params by reference (they are originally PRect).
> So maybe it will be still good to fix Types.IntersectRect to conform?

Yes. It should be improved.

Michael.


More information about the fpc-devel mailing list