[gnutls-dev] Building GnuTLS 1.6.1 under Mac OS X (fwd)
rks at mur.at
Fri Jan 26 22:08:29 CET 2007
Simon Josefsson schrieb:
> Matthias Scheler <tron at NetBSD.org> writes:
>>> the C++ library included in "gnutls" 1.6.1 doesn't build under Mac OS X
>>> because of a compiler bug. Apple's GCC apparently doesn't handle calling
>>> pure virtual function in constructors and desctrutors properly, see here:
>>> I've attached two patches taken from NetBSD's "pkgsrc" which inline
>>> the copy constructor of the "credentials" class under Mac OS X. That
>>> fixes the build problem for me under Mac OS 10.4.8 using the G++
>>> compiler from Xcode tools 2.4.1.
> Hi! While I really dislike adding #if's to work around compiler bugs
> (people should fix their compilers), I'm not familiar enough with C++
> or the GnuTLS C++ library to offer any better solution. I have
> installed the patch, with a comment about removing it in a few years.
I think that the "compiler bug" is described in the link is actually
the relevant snippet:
static MyConcreteClass rClass;
Note that the return type is MyAbstractClass, but the function tries to
return MyConcreteClass. So the return value is implicitely converted to
its base class, it is "sliced". (The function being called in a
constructor has nothing to do with it.) For virtual functions to work,
the object must to acessed via pointer or reference.
I looked up the mail that reported the error, and it seems that the
compiler fails to create an instance of the set_ptr() member function
in the object file. In this case, I would try to uninline set_ptr().
This can hardly be a performance problem and should fix the linker error :-)
Rupert Kittinger-Sereinig <rks at mur.at>
More information about the Gnutls-devel