This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Exception allocation on MinGW looses ::GetLastError() value
- From: Jonathan Wakely <jwakely dot gcc at gmail dot com>
- To: Timothy Madden <terminatorul at gmail dot com>
- Cc: gcc-help at gcc dot gnu dot org
- Date: Wed, 28 Mar 2012 20:51:59 +0100
- Subject: Re: Exception allocation on MinGW looses ::GetLastError() value
- References: <jkvmtp$j0m$1@dough.gmane.org>
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.