This is a continuation of Coccoliso's post http://www.firewing.info/forum/viewtopic.php?f=5&t=213
He marked that thread 'solved', so I figured I'd post them here so they're documented.
toolsuite: FW16 v1007B7, optimization -O1
- Code: Select all
#option _gccOptimise = O1
// opt -O1 issue: if this function is never called by main then compiler generates
// 'Error[]: Constant expression violates subrange bounds'
// other than that, the routine appears to work when it's called by main
private function conv(s as string) as uinteger
dim ii as uinteger = 0
ii.bytes(3) = cbyte(s(0))
ii.bytes(2) = cbyte(s(1))
ii.bytes(1) = cbyte(s(2))
ii.bytes(0) = cbyte(s(3))
return ii
end function
sub Main()
dim s as string
// set an initial value for i
dim i as uinteger = 1234
// change value of i
i.bytes(3) = cbyte("T")
i.bytes(2) = cbyte("E")
i.bytes(1) = cbyte("S")
i.bytes(0) = cbyte("T")
// at this point i = 0x54 45 53 54 (verified w/debugger watch)
// convert i to a string
// opt -O1 issue: this sets s = "1234" (the initial value), not current value for i
s = str(i)
dim j as uinteger = 4321
// opt -O1 issue: this dosn't change the value of j... it remains as set above
// also, commenting this line generates error for 'conv()' function
j = conv(s)
while true
end while
end sub
With optimization set to '-O0' all seems ok
