public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/40918] New: uncaught_exception() returns wrong (inverted) value if some exception have crossed a DLL boundary before
@ 2009-07-30 20:18 andriys at gmail dot com
2010-01-26 12:16 ` [Bug target/40918] " andriys at gmail dot com
0 siblings, 1 reply; 2+ messages in thread
From: andriys at gmail dot com @ 2009-07-30 20:18 UTC (permalink / raw)
To: gcc-bugs
I was not able to reproduce the bug on Linux, so I assume this is a
Windows-specific.
If an exception is generated inside shared library (DLL), then crosses the
DLL-boundary and gets caught in some other module, the std::uncaught_exception
will always return wrong (inverted) value from now on. Here's a small test
case.
The DLL (throw.dll) contains just a single function that throws an exception:
throw.cpp
~~~~~~~~~
void do_throw(void)
{
throw("");
}
The test program (test.exe) is linked against throw.dll:
test.cpp
~~~~~~~~
#include <exception>
#include <iostream>
bool b;
void do_throw(void);
struct UE
{
~UE()
{
b = std::uncaught_exception();
}
};
int main(void)
{
try
{
do_throw();
}
catch (...)
{
}
try
{
UE ue;
throw "";
}
catch (...)
{
}
std::cout << "Expecting 'true', got " << (b ? "'true'" : "'false'") <<
std::endl;
{
UE ue;
}
std::cout << "Expecting 'false', got " << (b ? "'true'" : "'false'") <<
std::endl;
return 0;
}
test.exe produces the following output:
C:\TEMP\bug>test.exe
Expecting 'true', got 'false'
Expecting 'false', got 'true'
If we comment out the call to do_throw(), std::uncaught_exception will work as
expected. If we put do_throw() in a statically linked module,
std::uncaught_exception will work as expected as well.
--
Summary: uncaught_exception() returns wrong (inverted) value if
some exception have crossed a DLL boundary before
Product: gcc
Version: 4.4.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: andriys at gmail dot com
GCC host triplet: mingw32
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40918
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-01-16 9:41 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <bug-40918-4@http.gcc.gnu.org/bugzilla/>
2012-01-16 9:57 ` [Bug target/40918] uncaught_exception() returns wrong (inverted) value if some exception have crossed a DLL boundary before ktietz at gcc dot gnu.org
2009-07-30 20:18 [Bug c++/40918] New: " andriys at gmail dot com
2010-01-26 12:16 ` [Bug target/40918] " andriys at gmail dot com
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).