-
September 3rd, 2012, 10:42 AM
#1
Compiler bug - Fast Code does not give same results as No Optmization
The following program gives different results when comiled for Fast Code versus No Optimization.
When running in the IDE the results are the same as No Optmization.
But, when compiled for Fast Code, the exe gives different results.
In ths example, the after setting the FltData array value, when reading the same value it does not return the value that was just set.
Changing little things in the code changes the results - like removing the for loop, for example.
If this one example shows that the results can be incorrect with FAST CODE optimization, how can I trust Fast Code for any of my projects?
Code:
Option Explicit
Const COL_FLTS = 1
Const COL_FTIME = 2
Public FltData(100, 7, 1) As Long
Public xCOL_FTIME As Long, xCOL_FLTS As Long
Sub Main()
Dim x As Long, j As Long
Dim rw As Long, mon As Long, comment As String
rw = 1
mon = 0
comment = "main "
xCOL_FLTS = 1: xCOL_FTIME = 2
Call testLongArray(rw, mon, "testlong #1")
'Call testLongArray(rw, mon, "testlong #2")
FltData(rw, COL_FLTS, mon) = FltData(rw, COL_FLTS, mon) + 1000
x = FltData(rw, COL_FTIME, mon) + 100
FltData(rw, COL_FTIME, mon) = x
For j = 1 To 12
Next j
If x <> FltData(rw, COL_FTIME, mon) Then
MsgBox (comment & " no joy " + Str(x) + Str(FltData(rw, COL_FTIME, mon)) + Str(FltData(rw, COL_FLTS, mon)))
Else
MsgBox (comment & " OK " + Str(x) + Str(FltData(rw, COL_FTIME, mon)) + Str(FltData(rw, COL_FLTS, mon)))
End If
Call testLongArray(rw, mon, "testlong #3 ")
End Sub
Function testLongArray(ByVal rw As Long, ByVal mon As Long, ByVal comment As String)
Dim j As Long, x As Long
FltData(rw, COL_FLTS, mon) = FltData(rw, COL_FLTS, mon) + 10
x = FltData(rw, COL_FTIME, mon) + 100
FltData(rw, COL_FTIME, mon) = x
For j = 1 To 12
Next j
If x <> FltData(rw, COL_FTIME, mon) Then
MsgBox (comment & " no joy" + Str(x) + Str(FltData(rw, COL_FTIME, mon)) + Str(FltData(rw, COL_FLTS, mon)))
Else
MsgBox (comment & " OK " + Str(x) + Str(FltData(rw, COL_FTIME, mon)) + Str(FltData(rw, COL_FLTS, mon)))
End If
End Function
Last edited by kreniska; September 4th, 2012 at 10:55 AM.
-
September 4th, 2012, 10:48 AM
#2
Re: Compiler bug - Fast Code does not give same results as No Optmization
Looks like you just did! Test, test, test...
-
September 4th, 2012, 06:17 PM
#3
Re: Compiler bug - Fast Code does not give same results as No Optmization
Interesting, I have never saw an issue and have been compiling for fast code for over 10 years now. Of course I rarely have a need for multidimensional arrays.
I tryed the code in the OP and I get the exact same results in the IDE and from the compiled EXE set to compile for fast code.
Are you using any other options in the compiler?
Always use [code][/code] tags when posting code.
-
September 4th, 2012, 09:50 PM
#4
Re: Compiler bug - Fast Code does not give same results as No Optmization
Might be Muilti-Core Setup. Quad or i7? What OS?
-
September 5th, 2012, 11:05 AM
#5
Re: Compiler bug - Fast Code does not give same results as No Optmization
I tested on a Dual Core CPU Windows XP MCE SP3 worked fine for me
Always use [code][/code] tags when posting code.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|