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

Jonas Maebe jonas.maebe at elis.ugent.be
Tue Oct 26 16:18:20 CEST 2010


On 26 Oct 2010, at 16:12, Sergei Gorelkin wrote:

> zeljko пишет:
>> On Tuesday 26 October 2010 15:13, Felipe Monteiro de Carvalho wrote:
>>> On Tue, Oct 26, 2010 at 3:14 PM, zeljko <zeljko at holobit.net> wrote:
>>>> No, I've opened an issue and Jonas closed with good explanation -  
>>>> we had
>>>> misusage of IntersectRect in gtk/gtk2 interfaces (I've fixed  
>>>> both) ... so
>>>> not bug.
>>> I guess it depends on how you see it.
>>>
>>> Anyway, the solution would be trivial, just store the inputs in  
>>> local vars.
>> I know, but generally speaking Jonas is correct, but you too :). I  
>> don't like current fpc solution too, but can live with it.
> 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).


Jonas


More information about the fpc-devel mailing list