CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Aug 2012
    Posts
    2

    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.

  2. #2
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: Compiler bug - Fast Code does not give same results as No Optmization

    Looks like you just did! Test, test, test...
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  3. #3
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    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.

  4. #4
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: Compiler bug - Fast Code does not give same results as No Optmization

    Might be Muilti-Core Setup. Quad or i7? What OS?
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  5. #5
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    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
  •  





Click Here to Expand Forum to Full Width

Featured