Forum Index
Function Return Optimization Bug

 
Author Message
mikep



Joined: 24 Sep 2005
Location: Austin, TX

Posted: 23 December 2006, 16:24 PM    Post subject: Function Return Optimization Bug

The following example code shows the problem:
Code:
Private i as Integer
Private x as Byte

Sub Main()
   i = 20
   Debug.Print CStr(i)
   Call Func()
   ' Problem shows up with value of i is unchanged by call to Func
   Debug.Print CStr(i)
End Sub

Public Sub Func()
   i = SetCode()
   ' Uncomment the following line and Main prints the correct result
   'Debug.Print CStr(i)
End Sub

Function SetCode() as Integer
   SetCode = 3
   ' wrong code generated for line above (value not saved on stack)
   ' the following line is needed to see the problem
   x = 23
End Function

The two Debug.Print statements in Main() show the same value. Uncommenting the line in Func() shows the correct result of 20 and then 3.
Back to top
dkinzer
Site Admin


Joined: 03 Sep 2005
Location: Portland, OR

Posted: 28 December 2006, 4:34 AM    Post subject:

The cause of this problem has been isolated and a solution has been implemented. It is currently in the process of being tested.
Back to top
Display posts from previous:   
Page 1 of 1

 



ZBasic Microcontrollers Home
All content Copyright © 2005, 2006, 2007, 2008, 2009, 2010 Elba Corp. All Rights Reserved.
Opinions expressed in posts are those of the author and not necessarily those of Elba Corp.
Powered by phpBB © 2001, 2005 phpBB Group