set addition bug?

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

set addition bug?

Adam Naumowicz
Hello,

I'd like to know if this is a known issue, or a new bug.

With the following code:
------------------
program tester;

type SomeType = ( SomeElem );

const ElemSet = [ SomeElem ];

begin
    writeln(SomeElem in ElemSet);
    writeln(SomeElem in (ElemSet + []));
end.
------------------

one gets:

TRUE
FALSE

while it should rather be

TRUE
TRUE

The problem concerns FPC 2.2.0 on i386/Linux. Actually, I was tracing a
bug that was only visible with 2.2.0 while the 2.0.0 version of the
compiler did not produce an errorneous code on that. Unfortunately, I
didn't succeed to separate a small snippet of code responsible for that -
in that case, however, the set after the '+' was another set constant, not
an empty set, so the problem is rather general. As I said, with 2.0.0 the
boolean value was correct, while with 2.2.0 it was plain wrong.

Best regards,
Adam Naumowicz

======================================================================
Department of Applied Logic            fax. +48 (85) 745-7662
Institute of Computer Science          tel. +48 (85) 745-7559 (office)
University of Bialystok                e-mail: [hidden email]
Sosnowa 64, 15-887 Bialystok, Poland   http://math.uwb.edu.pl/~adamn/
======================================================================

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: set addition bug?

Adam Naumowicz
Hello again,

On Mon, 11 Feb 2008, Adam Naumowicz wrote:

> Hello,
>
> I'd like to know if this is a known issue, or a new bug.
>
> With the following code:
> ------------------
> program tester;
>
> type SomeType = ( SomeElem );
>
> const ElemSet = [ SomeElem ];
>
> begin
>   writeln(SomeElem in ElemSet);
>   writeln(SomeElem in (ElemSet + []));
> end.
> ------------------
>
> one gets:
>
> TRUE
> FALSE
>
> while it should rather be
>
> TRUE
> TRUE
>
> The problem concerns FPC 2.2.0 on i386/Linux. Actually, I was tracing a bug
> that was only visible with 2.2.0 while the 2.0.0 version of the compiler did
> not produce an errorneous code on that. Unfortunately, I didn't succeed to
> separate a small snippet of code responsible for that - in that case,
> however, the set after the '+' was another set constant, not an empty set, so
> the problem is rather general. As I said, with 2.0.0 the boolean value was
> correct, while with 2.2.0 it was plain wrong.
It seems I've found an example that produces 'FALSE' with 2.2.0 and 'TRUE'
with 2.0.0 trying to eliminate my code as much as possible - the piece
is still a bit longish, so I attach it as a separate file - it seems,
however, that removing lines any further 'hides' the bug.

I hope it will help you find the solution for this nasty problem.

Best regards,

Adam Naumowicz

======================================================================
Department of Applied Logic            fax. +48 (85) 745-7662
Institute of Computer Science          tel. +48 (85) 745-7559 (office)
University of Bialystok                e-mail: [hidden email]
Sosnowa 64, 15-887 Bialystok, Poland   http://math.uwb.edu.pl/~adamn/
======================================================================

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

tester.pas (1K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: set addition bug?

Peter Vreman
Adam Naumowicz wrote:

> Hello again,
>
> On Mon, 11 Feb 2008, Adam Naumowicz wrote:
>
>> Hello,
>>
>> I'd like to know if this is a known issue, or a new bug.
>>
>> With the following code:
>> ------------------
>> program tester;
>>
>> type SomeType = ( SomeElem );
>>
>> const ElemSet = [ SomeElem ];
>>
>> begin
>>   writeln(SomeElem in ElemSet);
>>   writeln(SomeElem in (ElemSet + []));
>> end.
>> ------------------
>>
>> one gets:
>>
>> TRUE
>> FALSE
>>
>> while it should rather be
>>
>> TRUE
>> TRUE
>>
>> The problem concerns FPC 2.2.0 on i386/Linux. Actually, I was tracing
>> a bug that was only visible with 2.2.0 while the 2.0.0 version of the
>> compiler did not produce an errorneous code on that. Unfortunately, I
>> didn't succeed to separate a small snippet of code responsible for
>> that - in that case, however, the set after the '+' was another set
>> constant, not an empty set, so the problem is rather general. As I
>> said, with 2.0.0 the boolean value was correct, while with 2.2.0 it
>> was plain wrong.
>
> It seems I've found an example that produces 'FALSE' with 2.2.0 and
> 'TRUE' with 2.0.0 trying to eliminate my code as much as possible - the
> piece is still a bit longish, so I attach it as a separate file - it
> seems, however, that removing lines any further 'hides' the bug.
>
> I hope it will help you find the solution for this nasty problem.

Fixed in 2.3.1 in r10311.


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: set addition bug?

Adam Naumowicz
Hi Peter,

On Tue, 12 Feb 2008, Peter Vreman wrote:

> Adam Naumowicz wrote:
>> Hello again,
>>
>> On Mon, 11 Feb 2008, Adam Naumowicz wrote:
>>
>>> Hello,
>>>
>>> I'd like to know if this is a known issue, or a new bug.
>>>
>>> With the following code:
>>> ------------------
>>> program tester;
>>>
>>> type SomeType = ( SomeElem );
>>>
>>> const ElemSet = [ SomeElem ];
>>>
>>> begin
>>>   writeln(SomeElem in ElemSet);
>>>   writeln(SomeElem in (ElemSet + []));
>>> end.
>>> ------------------
>>>
>>> one gets:
>>>
>>> TRUE
>>> FALSE
>>>
>>> while it should rather be
>>>
>>> TRUE
>>> TRUE
>>>
>>> The problem concerns FPC 2.2.0 on i386/Linux. Actually, I was tracing a
>>> bug that was only visible with 2.2.0 while the 2.0.0 version of the
>>> compiler did not produce an errorneous code on that. Unfortunately, I
>>> didn't succeed to separate a small snippet of code responsible for that -
>>> in that case, however, the set after the '+' was another set constant, not
>>> an empty set, so the problem is rather general. As I said, with 2.0.0 the
>>> boolean value was correct, while with 2.2.0 it was plain wrong.
>>
>> It seems I've found an example that produces 'FALSE' with 2.2.0 and 'TRUE'
>> with 2.0.0 trying to eliminate my code as much as possible - the piece is
>> still a bit longish, so I attach it as a separate file - it seems, however,
>> that removing lines any further 'hides' the bug.
>>
>> I hope it will help you find the solution for this nasty problem.
>
> Fixed in 2.3.1 in r10311.

Thanks a lot for your quick response. Surely it solves the problem with
empty set as the second parameter. But I'm not sure if the other code I
sent later would also be fixed? - apparently that one had incorrect
valuation when tested with official 2.2.0 for Win32 - and there the second
argument was nonempty.

What do you think?

Best,

Adam

======================================================================
Department of Applied Logic            fax. +48 (85) 745-7662
Institute of Computer Science          tel. +48 (85) 745-7559 (office)
University of Bialystok                e-mail: [hidden email]
Sosnowa 64, 15-887 Bialystok, Poland   http://math.uwb.edu.pl/~adamn/
======================================================================

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: set addition bug?

Peter Vreman
>> Fixed in 2.3.1 in r10311.
>
> Thanks a lot for your quick response. Surely it solves the problem with
> empty set as the second parameter. But I'm not sure if the other code I
> sent later would also be fixed? - apparently that one had incorrect
> valuation when tested with official 2.2.0 for Win32 - and there the
> second argument was nonempty.
>
> What do you think?

The other code with "writeln( a in (FrmElKinds + TermElKinds));" doesn't
fail for me with neither 2.2.0 or 2.3.1 or an old 2.0.2.

Peter
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: set addition bug?

Adam Naumowicz
On Tue, 12 Feb 2008, Peter Vreman wrote:

>>> Fixed in 2.3.1 in r10311.
>>
>> Thanks a lot for your quick response. Surely it solves the problem with
>> empty set as the second parameter. But I'm not sure if the other code I
>> sent later would also be fixed? - apparently that one had incorrect
>> valuation when tested with official 2.2.0 for Win32 - and there the second
>> argument was nonempty.
>>
>> What do you think?
>
> The other code with "writeln( a in (FrmElKinds + TermElKinds));" doesn't fail
> for me with neither 2.2.0 or 2.3.1 or an old 2.0.2.

Now I see the problem - I didn't notice that the Delphi compatibility flag
is also crucial here:

C:\adam\internal\kernel>c:\fpc\2.2.0\bin\i386-win32\ppc386 -Sd tester.pas
Free Pascal Compiler version 2.2.0 [2007/09/09] for i386
Copyright (c) 1993-2007 by Florian Klaempfl
Target OS: Win32 for i386
Compiling tester.pas
Linking tester.exe
58 lines compiled, 0.8 sec, 23760 bytes code, 1272 bytes data

C:\adam\internal\kernel>tester
FALSE

C:\adam\internal\kernel>c:\fpc\2.2.0\bin\i386-win32\ppc386  tester.pas
Free Pascal Compiler version 2.2.0 [2007/09/09] for i386
Copyright (c) 1993-2007 by Florian Klaempfl
Target OS: Win32 for i386
Compiling tester.pas
Linking tester.exe
58 lines compiled, 0.9 sec, 23632 bytes code, 1208 bytes data

C:\adam\internal\kernel>tester
TRUE

Best,

Adam

======================================================================
Department of Applied Logic            fax. +48 (85) 745-7662
Institute of Computer Science          tel. +48 (85) 745-7559 (office)
University of Bialystok                e-mail: [hidden email]
Sosnowa 64, 15-887 Bialystok, Poland   http://math.uwb.edu.pl/~adamn/
======================================================================

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal