I tried to execute this piece of code:
- vb6 IDE (OK)
- vb6 exe (No optimization) (OK)
- vb6 exe (p-code) (OK)
- vb6 exe (Optimize for Fast Code and checked "Remove Integer Overflow Checks") (OK)
- vb6 exe (Optimize for Fast Code) reports the error "Overflow" ???
- Changing &H8000 to -32768 and optimization is on (OK) ???
- Changing &H8000 to &H80000000 and declaring a as Long, b as Long has the same effect
- b = a + 2 has the same effect
Any logical explanation?
By the way, this code:
works fine.
System information:
OS: Microsoft Windows 7 Professional 32 bit
VB Version: 6.1.7601 Service Pack 1 Build 7601
Code:
Private Sub Form_Load()
Dim a As Integer, b As Integer
a = &H8000 ' INT_MIN
b = a + 1 ' b = a -1 is obvious underflow!
b = b - a
End Sub
- vb6 exe (No optimization) (OK)
- vb6 exe (p-code) (OK)
- vb6 exe (Optimize for Fast Code and checked "Remove Integer Overflow Checks") (OK)
- vb6 exe (Optimize for Fast Code) reports the error "Overflow" ???
- Changing &H8000 to -32768 and optimization is on (OK) ???
- Changing &H8000 to &H80000000 and declaring a as Long, b as Long has the same effect
- b = a + 2 has the same effect
Any logical explanation?
By the way, this code:
Code:
Private Sub Form_Load()
Dim a As Integer, b As Integer
a = &H7FFF
b = a - 1
b = b - a
End Sub
System information:
OS: Microsoft Windows 7 Professional 32 bit
VB Version: 6.1.7601 Service Pack 1 Build 7601