Boost logo

Boost :

From: JOAQUIN LOPEZ MU?Z (joaquin_at_[hidden])
Date: 2004-11-28 17:03:43

Allow me to repost this, since seems it has
gone thru the list indavertently. I'd be grateful
if people with various versions of GCC can try
the snippet so as to determine to which extent
the problem shows.

Original post follows:

The following program:

#include <boost/aligned_storage.hpp>

struct foo
  foo(int x){}

  boost::aligned_storage<sizeof(int)> a;

int main()
  foo f(5);

  return 0;

fails in GCC 3.2 20020927 with the error:

/usr/local/boost_1_32_0/boost/aligned_storage.hpp: In function `int
/usr/local/boost_1_32_0/boost/aligned_storage.hpp:75: `
   boost::aligned_storage<size_, alignment_>::aligned_storage(const
   boost::aligned_storage<size_, alignment_>&) [with unsigned int size_
= 4,
   unsigned int alignment_ = 0ffffffff]' is private

Digging into aligned_storage.hpp, I find the following workaround:


private: // noncopyable

    aligned_storage(const aligned_storage&);
    aligned_storage& operator=(const aligned_storage&);

#else // gcc2.x

public: // _should_ be noncopyable, but GCC compiler emits error

    aligned_storage(const aligned_storage&);
    aligned_storage& operator=(const aligned_storage&);

#endif // gcc2.x workaround

So, it seems like the problem was known but incorrectly assumed
to affect GCC 2.x only.
Anyone objects to extending the workaround to GCC 3.x? It remains
to know whether this problem (that seems like an incorrect application
of the copy ellision rules) persists in GCC 3.4.x, and in case it is
fixed, which last version is for which we should have the workaround.

Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo

Boost list run by bdawes at, gregod at, cpdaniel at, john at