# PureBasic Forum

 It is currently Mon Feb 17, 2020 7:24 am

 All times are UTC + 1 hour

 Page 2 of 2 [ 21 posts ] Go to page Previous  1, 2
 Print view Previous topic | Next topic
Author Message
 Post subject: Re: [PB511] AND OR expression, wrong resultPosted: Tue Apr 09, 2013 10:00 am

Joined: Thu Jun 07, 2007 3:25 pm
Posts: 3759
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...

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

 Post subject: Re: [PB511] AND OR expression, wrong resultPosted: Wed Nov 06, 2013 10:14 am
 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

 Post subject: Re: [PB511] AND OR expression, wrong resultPosted: Wed Nov 06, 2013 10:19 am

Joined: Wed Nov 12, 2008 5:01 pm
Posts: 1073
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

_________________
Torrent client - pbTorrent (source code); Create driver in PureBasic.

Top

 Post subject: Re: [PB511] AND OR expression, wrong resultPosted: Wed Nov 06, 2013 10:29 am

Joined: Mon Jul 25, 2005 3:51 pm
Posts: 3618
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.

_________________

Top

 Post subject: Re: [PB511] AND OR expression, wrong resultPosted: Wed Nov 06, 2013 11:45 am
 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

 Post subject: Re: [PB511] AND OR expression, wrong resultPosted: Wed Nov 06, 2013 12:09 pm

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

Top

 Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending
 Page 2 of 2 [ 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 4 guests

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

Search for:
 Jump to:  Select a forum ------------------ PureBasic    Coding Questions    Game Programming    3D Programming    Assembly Programming    The PureBasic Editor    The PureBasic Form Designer    General Discussion    Feature Requests and Wishlists    Tricks 'n' Tips Bug Reports    Bugs - Windows    Bugs - Linux    Bugs - Mac OSX    Bugs - Documentation OS Specific    AmigaOS    Linux    Windows    Mac OSX Miscellaneous    Announcement    Off Topic Showcase    Applications - Feedback and Discussion    PureFORM & JaPBe    TailBite