Bug#94955: Linking with libstdc++ changes behavior of a program (which does not require libstdc++)
Package: libstdc++2.10-glibc2.2
Version: 1:2.95.3-8
==== BEGIN TRANSCRIPT ================================================
phil@resume:~% cat foo.cpp
#include <unistd.h>
class EX
{
public:
EX() { write(2,"XCR\n",4); }
virtual ~EX() { write(2, "XD\n", 3); }
EX(const EX&) { write(2, "XCP\n", 4); }
};
class EY : public virtual EX
{
public:
EY() { write(2,"YCR\n",4); }
~EY() { write(2, "YD\n", 3); }
EY(const EY&) { write(2, "YCP\n", 4); }
};
int main()
{
try {
throw EY();
}
catch(const EY&)
{
}
return 0;
}
phil@resume:~% gcc -o foo foo.cpp
phil@resume:~% ./foo
XCR
YCR
XCR
YCP
YD
XD
YD
XD
phil@resume:~% gcc -o foo foo.cpp -lstdc++
phil@resume:~% ./foo
XCR
YCR
XCR
YCP
YD
XD
zsh: 11278 illegal hardware instruction ./foo
phil@resume:~%
==== END TRANSCRIPT ================================================
This program does not require libstdc++... However, if libstdc++ is
linked in, the program crashes...
This problem occurs only on the mips architecture.
Well, actually, a bigger program (aleph package) has the same problem
(works when NOT linked with libstdc++, crashes when linked with
libstdc++) on both mips and arm. I isolated the problem to this simple
test case on mips.
Phil.
Reply to: