Re: Exception allocation on MinGW looses ::GetLastError() value
|[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]|
On 28 March 2012 19:56, Timothy Madden wrote: > Hello > > I just wrote a simple MinGW program (more or less, the library templates > there are not necessarily small) where I built an exception class around the > "System Error Codes" in Win API returned by ::GetLastError() function. > > Than I want to throw such an exception, with the call to GetLastError > directly as the argument to the constructor: > > throw WinapiException(::GetLastError()) > > Much to my surprise, ::GetLastError() appears to return 0 (success), even > after an API function returns failure. I used an API monitoring tool > (listing all calls to .dll functions from my program), and I find that upon > the first throw statement encountered, libgcc_s_dw2-1.dll also calls > ::CreateSemaphore() and ::TlsAlloc(), and even ::GetLastError(), before my > WinapiException() constructor gets called. I used gdb to break on > ::CreateSemaphore, to confirm the backtrace. I guess it is something like an > "exception allocation code" generated by the compiler, with library support. > > Which is ok, except that it looses the value for ::GetLastError(). > > I don't want to be blunt, but it kind of breaks the API function, and > regular users do not know to look for and use an API monitoring tool. Can > this be fixed please ? Not via this mailing list, no. It sounds like a bug so please report it to bugzilla, thanks.