Page 1 of 1

A bug? Hm... seems like

Posted: Fri Dec 12, 2014 11:06 pm
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?

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

Posted: Fri Dec 12, 2014 11:21 pm
by IdeasVacuum
This is a string: "Byte = " so you can only add strings to it: + StrU(Byte, #PB_Byte)

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

Posted: Fri Dec 12, 2014 11:26 pm
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.

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

Posted: Fri Dec 12, 2014 11:30 pm
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! :)

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

Posted: Fri Dec 12, 2014 11:31 pm
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

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

Posted: Fri Dec 12, 2014 11:39 pm
by Shield
The first code gives 2 / 2, luis' code yields 1 / 0.
I tested with an older version, PB 5.30 x86.

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

Posted: Fri Dec 12, 2014 11:40 pm
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!

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

Posted: Sat Dec 13, 2014 12:45 am
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

Re: A bug? Hm... seems like

Posted: Sat Dec 13, 2014 1:24 am
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

Re: A bug? Hm... seems like

Posted: Sat Dec 13, 2014 2:57 am
by Shield
Well...I guess :?:
I usually also don't use it because I like to have precise control over formatting.

Re: A bug? Hm... seems like

Posted: Sat Dec 13, 2014 5:43 am
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.