Ken MacKay
|
Some compile errors moving from gcc 3.3.5 to 4.2.1
|
Ken MacKay
09/12/2007 9:13 PM
post1121
|
Some compile errors moving from gcc 3.3.5 to 4.2.1
I am trying out the ported gcc 4.2, and while compiling our project I noticed some issues which I believe are compiler-
related:
1. Trouble with copy constructors:
/usr/qnx630/host/qnx6/x86/usr/bin/QCC -Wp,-MD,x86/ServerSocket.dep -V4.2.1,gcc_ntox86 -I/trunk -g -Wno-uninitialized -o
x86/ServerSocket.o -c ServerSocket.cpp
In file included from /usr/qnx630/target/qnx6/usr/include/cpp/xiosbase:7,
from /usr/qnx630/target/qnx6/usr/include/cpp/streambuf:7,
from /usr/qnx630/target/qnx6/usr/include/cpp/xlocnum:10,
from /usr/qnx630/target/qnx6/usr/include/cpp/ios:7,
from /usr/qnx630/target/qnx6/usr/include/cpp/ostream:7,
from /usr/qnx630/target/qnx6/usr/include/cpp/istream:7,
from /usr/qnx630/target/qnx6/usr/include/cpp/string:7,
from /usr/qnx630/target/qnx6/usr/include/boost/function/function_base.hpp:14,
from /usr/qnx630/target/qnx6/usr/include/boost/function/detail/prologue.hpp:16,
from /usr/qnx630/target/qnx6/usr/include/boost/function.hpp:22,
from ServerSocket.h:15,
from ServerSocket.cpp:15:
/usr/qnx630/target/qnx6/usr/include/yvals.h: In copy constructor 'std::_Locinfo::_Locinfo(const std::_Locinfo&)':
/usr/qnx630/target/qnx6/usr/include/yvals.h:301: error: 'std::_Lockit::_Lockit(const std::_Lockit&)' is private
/usr/qnx630/target/qnx6/usr/include/cpp/xlocinfo:49: error: within this context
/usr/qnx630/target/qnx6/usr/include/cpp/xlocale: In constructor 'std::codecvt<wchar_t,
char, _Mbstatet>::codecvt(std::size_t)':
/usr/qnx630/target/qnx6/usr/include/cpp/xlocale:683: note: synthesized method 'std::_Locinfo::_Locinfo(const std::
_Locinfo&)' first required here
cc: /usr/qnx630/host/qnx6/x86/usr/lib/gcc/i386-pc-nto-qnx6.3.0/4.2.1/cc1plus error 1
Class _Locinfo contains a _Lockit member, which has a private, undefined copy constructor, but _Locinfo does not. Then
when the compiler tries to generate the copy constructor for _Locinfo, it fails. I'm not sure why the compiler is
generating a copy constructor; perhaps that is the problem. The code in xlocale is similar to the following:
class codecvt
{
void _Init(const _Locinfo &)
{
}
codecvt()
{
_Init(_Locinfo()); // copy constructor is generated due to this line (why?)
}
}
I solved this problem by altering _Locinfo to have a private copy constructor, and modifying the files that reference it
so that the copy constructor is not called (changed _Init(_Locinfo()) to _Locinfo info; _Init(info);)
2. Problems linking:
/usr/qnx630/host/qnx6/x86/usr/bin/QCC -V4.2.1,gcc_ntox86 -o x86/select x86/select.o -Lx86 -Wl,-rpath,x86 -lsocket -
lcppunit
x86/select.o: In function `void boost::function1<void, ClientSocket*, std::allocator<void> >::assign_to<void (*
)(ClientSocket*)>(void (*)(ClientSocket*))':
/usr/qnx630/target/qnx6/usr/include/boost/function/function_template.hpp:645: undefined reference to `
__cxa_guard_acquire'
/usr/qnx630/target/qnx6/usr/include/boost/function/function_template.hpp:645: undefined reference to `
__cxa_guard_release'
cc: /usr/qnx630/host/qnx6/x86/usr/bin/ntox86-ld-2.17 error 1
You can see that the problem involves the Boost library. I am using the latest version of Boost (1.34.1). The problem
seems to be due to a static variable declaration in a function. I solved this problem by adding -fno-threadsafe-statics
to the compile flags.
3. Problems with exceptions:
Example code:
----- ex.cpp -----
#include <string>
class MyClass
{
public:
MyClass(std::string in) {} // no error if the parameter is an int
};
class MyException
{
MyException() {} // no error if there is no constructor defined
};
int main()
{
try
{
MyClass test("asdf"); // no error if this line is commented out
}
catch(MyException e) // no error if the...
View Full Message
|
|
|