This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/16170] New: Exception not caught with static binary if class uses sockets
- From: "Uwe dot Seimet at seimet dot de" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 24 Jun 2004 06:58:20 -0000
- Subject: [Bug c++/16170] New: Exception not caught with static binary if class uses sockets
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
Hello!
When compiling the C++ code below with
c++ -static test.cpp
I get this when running the result:
ws-091>./a.out
Throw it.
Segmentation fault
When compiling without -static I get this instead, which is the expected behaviour:
ws-091>./a.out
Throw it.
Got it.
The use of the -static option prevents the exception from being caught.
Note that when I comment out the ::socket or ::shutdown line the exception is
caught even when using -static.
I have the same problem with gcc 3.3.3 on a Linux platform as well. But on an
AMD64 platform with gcc 3.3.3 and 64 bit code everything is fine.
Best regards, Uwe
----
#include <cstdio>
#include <sys/socket.h>
#include <netinet/in.h>
class BaseSocket
{
public:
BaseSocket ();
~BaseSocket ();
int fd_;
};
BaseSocket::BaseSocket ()
{
fd_ = ::socket (PF_INET, SOCK_STREAM, IPPROTO_TCP);
}
BaseSocket::~BaseSocket ()
{
::shutdown (fd_, SHUT_RDWR);
}
int main (int argc, char ** argv)
{
try
{
printf("Throw it.\n");
throw "Hallo";
}
catch (...)
{
printf("Got it.\n");
}
BaseSocket * pSocket = new BaseSocket();
return 0;
}
--
Summary: Exception not caught with static binary if class uses
sockets
Product: gcc
Version: 3.4.0
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: Uwe dot Seimet at seimet dot de
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: i686-pc-linux-gnu
GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16170