It is currently Mon Jul 22, 2019 12:59 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 21 posts ]  Go to page Previous  1, 2
Author Message
 Post subject: Re: [PB511] AND OR expression, wrong result
PostPosted: Tue Apr 09, 2013 10:00 am 
Offline
Addict
Addict
User avatar

Joined: Thu Jun 07, 2007 3:25 pm
Posts: 3598
Location: Berlin, Germany
Jacobite wrote:
TBH I find it rather alarming that a such a fundamental error in the compiler has been left unfixed for so long, although I suppose in practice it would be fairly rare for it show up (otherwise, it would have been fixed before now). But still... :shock:

I agree.
However, in the course of time I got more or less accustomed to the fact that PB has many (partly fundamental) bugs. :(

_________________
Please excuse my flawed English. My native language is PureBasic.
Search
RSBasic's backups


Top
 Profile  
Reply with quote  
 Post subject: Re: [PB511] AND OR expression, wrong result
PostPosted: Wed Nov 06, 2013 10:14 am 
Offline
User
User

Joined: Sat Nov 12, 2011 7:21 pm
Posts: 59
New compiler seems to push the broken logic even further:
Code:
For i = 0 to 7

 a = i & 1
 b = i & 2
 c = i & 4

 Print("a = "+Str(a)+" b = "+Str(b)+" c = "+Str(c)+" ->")

 If Not a And Not b And Not c
   PrintN("True")
 Else
   PrintN("False")
 EndIf

Next i

result:
Code:
a = 0 b = 0 c = 0 ->False
a = 1 b = 0 c = 0 ->False
a = 0 b = 2 c = 0 ->True
a = 1 b = 2 c = 0 ->False
a = 0 b = 0 c = 4 ->False
a = 1 b = 0 c = 4 ->False
a = 0 b = 2 c = 4 ->False
a = 1 b = 2 c = 4 ->False

In PB 5.1, this still worked correctly.

Here now, the second "Not" is dropped -> expression is evaluated as "(Not a) And b And (Not c).
Works similar with "Or".
"And" and "Or" may be in the same priority class, but "Not" is clearly stated as higher in the manual.

I'm also not thrilled to see "If a And b Or c" as an example right there in the manual. After all it's known to be broken.

I'm rather puzzled how short circuit evaluation makes "Not b" turn to "b" - guess I'm not smart enough to grasp the concept.


Top
 Profile  
Reply with quote  
 Post subject: Re: [PB511] AND OR expression, wrong result
PostPosted: Wed Nov 06, 2013 10:19 am 
Offline
Addict
Addict

Joined: Wed Nov 12, 2008 5:01 pm
Posts: 1046
Location: Russia
Grunz wrote:
New compiler
Grunz wrote:
result:
In current version, other results.
Code:
a = 0 b = 0 c = 0 ->True
a = 1 b = 0 c = 0 ->False
a = 0 b = 2 c = 0 ->False
a = 1 b = 2 c = 0 ->False
a = 0 b = 0 c = 4 ->False
a = 1 b = 0 c = 4 ->False
a = 0 b = 2 c = 4 ->False
a = 1 b = 2 c = 4 ->False

_________________
Library XP_Menu_Lib - office menu; HID_Lib - USB Library
Torrent client - pbTorrent (source code); Create driver in PureBasic.


Top
 Profile  
Reply with quote  
 Post subject: Re: [PB511] AND OR expression, wrong result
PostPosted: Wed Nov 06, 2013 10:29 am 
Offline
Addict
Addict
User avatar

Joined: Mon Jul 25, 2005 3:51 pm
Posts: 3560
Location: Utah, USA
I confirm the same results as User_Russian when using PB v5.21 LTS beta 1 and running Grunz's test code. These results are now correct.

When running luis's code at the store of the thread I get incorrect results (that match his) of F,F,F,T.

_________________
Image


Top
 Profile  
Reply with quote  
 Post subject: Re: [PB511] AND OR expression, wrong result
PostPosted: Wed Nov 06, 2013 11:45 am 
Offline
User
User

Joined: Sat Nov 12, 2011 7:21 pm
Posts: 59
Sorry, looks like I posted into wrong thread then, as this seems to be a Linux only issue then:

Compiler version with broken results is :
PureBasic 5.21 LTS Beta 1 (Linux - x64) - (c) 2013 Fantaisie Software

5.20 x64 Linux works correctly for me too.

I did not expect Linux and Windows version to differ in that kind of stuff.


Top
 Profile  
Reply with quote  
 Post subject: Re: [PB511] AND OR expression, wrong result
PostPosted: Wed Nov 06, 2013 12:09 pm 
Online
Administrator
Administrator

Joined: Fri May 17, 2002 4:39 pm
Posts: 13595
Location: France
That's right, the linux issue is fixed.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 21 posts ]  Go to page Previous  1, 2

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye