On 03.03.2012 19:29, Earnie Boyd wrote:
> On Sat, Mar 3, 2012 at 6:32 AM, benjamin<bewei88@...> wrote:
>> this is the code snippet:
>> on MinGW 4.6.1 the output is : "dwLastError 0"
>> on MinGW 4.5.0 and 4.5.2 its : "dwLastError 1337" which is the desired
>> if i write the foobar function like this :
>> then it also works on 4.6.1 with "dwLastError 1337".
>> I dont know what exactly is going on, but i think it could be a MinGW bug.
>> What do you think?
> Well not, MinGW, particularly but maybe GCC. Does it work if you change
> throw Win32Exception(GetLastError());
> throw Win32Exception((DWORD)GetLastError());
Can this be fixed please ? I have just run into it, and I think it is a
bug because it breaks functionality in Windows API (from the user's
I used an API monitoring application, that would list all WinAPI
functions that are being called by my program, and so I find that on the
first throw statement (before the first Win32Exception is constructed)
there are several several other system calls before my call to
GetLastError(): malloc() which calls HeapAlloc(),
InterlockedIncrement(), InterlockedDecrement(), CreateSemaphore(),
TlsAlloc() and GetLastError().
Of these, CreateSempahore() was the first to reset the value of
The calls are listed as originating from that libgcc_s_dw2-1.dll file,
except for malloc which was originating from libstdc++.
I can understand that exceptions may need additional maintenance from
the support libraries, but I think such libraries should save and
restore the value of GetLastError() if they need to change it.
I can post the example program and the list of API and .dll calls if
anyone is interested.