Page 1 of 1

Protected NOT protected?

Posted: Sat Jun 18, 2011 6:53 am
by akee
Tailbite 1.4.7 with PB 4.51.
Tailbite First.pb and Second.pb. Then run Third.pb. Seems that the protected variable alpha$ gets shared.

First.pb

Code: Select all

Procedure$ First_Private(p1$)
  Protected alpha$ = ""
  alpha$ = p1$ + " first"
  ProcedureReturn alpha$
EndProcedure

ProcedureDLL$ First(p1$)
  ProcedureReturn First_Private(p1$)
EndProcedure
Second.pb

Code: Select all

Procedure$ Seconds_Private(p1$)
  Protected alpha$ = ""
  alpha$ = p1$ + " second"
  ProcedureReturn alpha$
EndProcedure

ProcedureDLL$ Seconds(p1$)
  ProcedureReturn Seconds_Private(p1$)
EndProcedure
Third.pb

Code: Select all

Debug First(Seconds("*"))   ; * second* second first

Procedure$ InFirst(p1$)
  Protected alpha$ = ""
  alpha$ = p1$ + " first"
  ProcedureReturn alpha$
EndProcedure

Procedure$ InSeconds(p1$)
  Protected alpha$ = ""
  alpha$ = p1$ + " second"
  ProcedureReturn alpha$
EndProcedure

Debug InFirst(InSeconds("*"))   ; * second first

Re: Protected NOT protected?

Posted: Sat Jun 18, 2011 10:19 am
by ABBKlaus
Its a known issue (the first one on the list) and has nothing to do with the protected keyword.

Re: Protected NOT protected?

Posted: Sun Jun 19, 2011 9:43 am
by akee
Tanks for the feedback ABBKlaus. Do you know if 4.60 fixes this? :)

Re: Protected NOT protected?

Posted: Sun Sep 11, 2011 11:06 am
by akee
Just retried this example with 4.60 RC1. This bug is not yet fixed... :(

Re: Protected NOT protected?

Posted: Mon Sep 12, 2011 9:37 am
by gnozal
akee wrote:Just retried this example with 4.60 RC1. This bug is not yet fixed... :(
It is not a PB bug, as PB libraries work fine.
It's a Tailbite issue (http://www.purebasic.fr/english/viewtopic.php?p=230189) related to the 'double PUSH dword [_PB_StringBasePosition]' in Purebasic.asm when a procedure returns a string.