Fix this 64-bit VBA compiler bug (temporary objects in IF clauses)
I found a serious bug in VBA 64-bit which basically stops our porting efforts and our customers migration to Office 64-bit. Steps to reproduce:
In a 64-bit VBA host (Access, Excel) add these files:
' (Class_Terminate is required to reproduce the bug) Private Sub Class_Terminate() End Sub
Function ReturnFalse(o As Object) As Boolean ReturnFalse = False End Function Sub test() Debug.Print ReturnFalse(New SomeClass) If ReturnFalse(New SomeClass) Then Debug.Print True Else Debug.Print False End If End Sub
Running 'test' in the VBA IDE returns the following output in 64-bit Access:
On a 32-Bit Access this yields:
Apparently the lifetime of temporary objects during evaulation of IF clauses is handled wrongly, resulting in memory overwrites (which would explain how a literal False can become True).
More Info: The error disappears, if we remove the Class_Terminate() sub, which should give you a better hint where to look for.
This error could be reproduced by me in
- Microsoft® Access® für Microsoft 365 MSO (16.0.14026.20294) 64-Bit
- Microsoft Access 2016 MSO (16.0.9029.2167) 64-Bit
- Microsoft Access 2013 (15.0.4420.1017) MSO (15.0.4420.1017) 64-Bit
Checked with Mac Office 365 and the bug is not there. It's a PC thing apparently.
Also on stackoverflow now: https://stackoverflow.com/questions/68034271/how-can-i-get-this-8-year-old-vba-64-bit-compiler-bug-fixed
Oh my, this thing replaces quote characters...
' is the single comment quote
" is the double quote.