A bug? Hm... seems like

Everything else that doesn't fall into one of the other PB categories.
es_91
Enthusiast
Enthusiast
Posts: 298
Joined: Thu Jan 27, 2011 12:00 pm
Location: DE

A bug? Hm... seems like

Post by es_91 »

I have a strange thing I can not explain.

Please help me understand this.

Code: Select all

Define Quad. q = #Null
Define Byte. b = #Null

Define Long. l = 0
Define Word1. w = 12
Define Word2. w = 14

Procedure. b MyProcedure (Byte. b)
  
  Debug "Byte = " + Byte
  
EndProcedure

MyProcedure (Long - (Word1 - Word2))

Quad = Quad + (Byte - MyProcedure (Long - (Word1 - Word2)))

This is taken from a code i wrote about date handling, months, years, leap years, etc. and heavily modified.

Why does the function receive different values?
Last edited by es_91 on Fri Dec 12, 2014 11:41 pm, edited 1 time in total.
:mrgreen:
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: A bug? No, just my lack of knowledge...

Post by IdeasVacuum »

This is a string: "Byte = " so you can only add strings to it: + StrU(Byte, #PB_Byte)
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
User avatar
Shield
Addict
Addict
Posts: 1021
Joined: Fri Jan 21, 2011 8:25 am
Location: 'stralia!
Contact:

Re: A bug? No, just my lack of knowledge...

Post by Shield »

IdeasVacuum wrote:This is a string: "Byte = " so you can only add strings to it: + StrU(Byte, #PB_Byte)
No, you can add numerical variables directly without using Str() / StrU(). This feature has been added quite some time ago.

@es_91: I get the same output, so I'm not sure I understand the issue here.
Image
Blog: Why Does It Suck? (http://whydoesitsuck.com/)
"You can disagree with me as much as you want, but during this talk, by definition, anybody who disagrees is stupid and ugly."
- Linus Torvalds
es_91
Enthusiast
Enthusiast
Posts: 298
Joined: Thu Jan 27, 2011 12:00 pm
Location: DE

Re: A bug? No, just my lack of knowledge...

Post by es_91 »

Shield wrote:@es_91: I get the same output, so I'm not sure I understand the issue here.
Shield, i get the following output:
PB Debugger wrote:Byte = 2
Byte = 0
I just tested this code with 32 Bit version of 5.31 PureBasic and it seems, it's a 64 Bit problem only. Could this even be a bug? Please test it with the 64 Bit version! :)
:mrgreen:
User avatar
luis
Addict
Addict
Posts: 3895
Joined: Wed Aug 31, 2005 11:09 pm
Location: Italy

Re: A bug? No, just my lack of knowledge...

Post by luis »

Code: Select all

EnableExplicit

; for x86 the bug is present for .b, .w 
; for x64 the bug is present for .b, .w, .l

; so when b2 is smaller than the architecture's native data type 

Define a
Define b1 = 1
Define b2.w = 2

Procedure MyProcedure (x)
 Debug "x = " + x
EndProcedure

MyProcedure (a - (b1 - b2))

a = a + (a - MyProcedure (a - (b1 - b2)))


Edit: typos
Last edited by luis on Sat Dec 13, 2014 12:03 am, edited 1 time in total.
"Have you tried turning it off and on again ?"
User avatar
Shield
Addict
Addict
Posts: 1021
Joined: Fri Jan 21, 2011 8:25 am
Location: 'stralia!
Contact:

Re: A bug? No, just my lack of knowledge...

Post by Shield »

The first code gives 2 / 2, luis' code yields 1 / 0.
I tested with an older version, PB 5.30 x86.
Image
Blog: Why Does It Suck? (http://whydoesitsuck.com/)
"You can disagree with me as much as you want, but during this talk, by definition, anybody who disagrees is stupid and ugly."
- Linus Torvalds
es_91
Enthusiast
Enthusiast
Posts: 298
Joined: Thu Jan 27, 2011 12:00 pm
Location: DE

Re: A bug? No, just my lack of knowledge...

Post by es_91 »

Ahm... so it's a bug? :?

When is the chance this gets fixed?

Thanks, Luis. You should post this in the bug section!
:mrgreen:
User avatar
luis
Addict
Addict
Posts: 3895
Joined: Wed Aug 31, 2005 11:09 pm
Location: Italy

Re: A bug? No, just my lack of knowledge...

Post by luis »

es_91 wrote:Ahm... so it's a bug? :?
It's a bug !
es_91 wrote: When is the chance this gets fixed?
Image
es_91 wrote: Thanks, Luis. You should post this in the bug section!
Moi ? OK, OK ....

http://www.purebasic.fr/english/viewtop ... =4&t=61218
Last edited by luis on Sun Jul 31, 2016 1:47 pm, edited 1 time in total.
"Have you tried turning it off and on again ?"
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: A bug? Hm... seems like

Post by IdeasVacuum »

No, you can add numerical variables directly without using Str() / StrU(). This feature has been added quite some time ago.
:oops:
I always avoid that change - is it 100% reliable in all cases?

Good spot btw Luis
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
User avatar
Shield
Addict
Addict
Posts: 1021
Joined: Fri Jan 21, 2011 8:25 am
Location: 'stralia!
Contact:

Re: A bug? Hm... seems like

Post by Shield »

Well...I guess :?:
I usually also don't use it because I like to have precise control over formatting.
Image
Blog: Why Does It Suck? (http://whydoesitsuck.com/)
"You can disagree with me as much as you want, but during this talk, by definition, anybody who disagrees is stupid and ugly."
- Linus Torvalds
Little John
Addict
Addict
Posts: 4791
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: A bug? Hm... seems like

Post by Little John »

IdeasVacuum wrote:
No, you can add numerical variables directly without using Str() / StrU(). This feature has been added quite some time ago.
:oops:
I always avoid that change - is it 100% reliable in all cases?
In certain cases, we have to be careful with using string autocasting,
see first post in this thread.
Post Reply