| Igor Tandetnik 2004-03-28, 10:32 pm |
| "Manoj Rath" <manoj@inspinc.ad> wrote in message
news:u2z4cofEEHA.3256@TK2MSFTNGP09.phx.gbl
> I am sending some sample code, which throws an Access Violation
> Exception in Run Time only in Release version.
>
> The ZIP file contains the source files and the solution/vcproj file,
> which can produce the access violation exception.
> This existed in VS 7.0 (MSDEV 2002), also exists in VS 7.1 (MSDEV
> 2003), doesn't exist in VS 6.0
> You will see the exception in release build only, debug works fine.
Yes, looks like a compiler bug. I've looked at the disassembly - the
compiler does not reload ECX register with &obj before calling
funcAfterException, assuming that it is still intact after the last
method call. Of course the register is destroyed by all the throwing and
catching. So funcAfterException gets garbage 'this' pointer.
When you uncomment the commented line, ECX is loaded with &cout and such
in the interim, after which the compiler correctly realizes that ECX
needs to be refreshed.
I'll report the problem to MS.
--
With best wishes,
Igor Tandetnik
"For every complex problem, there is a solution that is simple, neat,
and wrong." H.L. Mencken
|