[gnutls-dev] Building GnuTLS 1.6.1 under Mac OS X (fwd)

Simon Josefsson simon at josefsson.org
Wed Jan 31 12:29:09 CET 2007

Rupert Kittinger-Sereinig <rks at mur.at> writes:

> Hi Simon,
> I think that the "compiler bug" is described in the link is actually 
> correct behaviour.
> the relevant snippet:
> MyAbstractClass MyWrapperClass::getClass()
>      {
>          static MyConcreteClass rClass;
>          return rClass;
>      }

Hi Rupert!  My C++ knowledge is too weak to pattern-match that with
the code currently in GnuTLS.  includes/gnutls/gnutlsxx.h has:

class credentials
        credentials(gnutls_credentials_type_t t);
#if defined(__APPLE__) || defined(__MACOS__)
	/* FIXME: This #if is due to a compile bug in Mac OS X.  Give
	   it some time and then remove this cruft.  See also
	   lib/gnutlsxx.cpp. */
	credentials( credentials& c) {
	  type = c.type;
	  set_ptr( c.ptr());
	credentials( credentials& c);
        virtual ~credentials() { }
        gnutls_credentials_type_t get_type() const;
        friend class session;
        virtual void* ptr() const=0;
        virtual void set_ptr(void* ptr)=0;
        gnutls_credentials_type_t type;

and lib/gnutlsxx.cpp has:

#if !(defined(__APPLE__) || defined(__MACOS__))
/* FIXME: This #if is due to a compile bug in Mac OS X.  Give it some
   time and then remove this cruft.  See also
   includes/gnutls/gnutlsxx.h. */
credentials::credentials( credentials& c)
    this->type = c.type;
    this->set_ptr( c.ptr());

> 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 :-)

I'd really appreciate your help here.  What would your recommendation
be, more specifically?  The old code is the one which is used when the
newly added #if's are not chosen.  I've seen other bug reports too,
such as this failure:

>> verify-elf: ERROR: ./usr/lib/libgnutlsxx.so.13.2.2: undefined symbol: 
>> _ZN6gnutls11credentials7set_ptrEPv

But that may actually be the same, I don't know...


More information about the Gnutls-devel mailing list