Boost logo

Boost :

From: Joaquín Mª López Muñoz (joaquin_at_[hidden])
Date: 2004-11-26 11:03:29


The following program:

#include <boost/aligned_storage.hpp>

struct foo
{
  foo(int x){}

private:
  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
main()':
/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:

#if !BOOST_WORKAROUND(__GNUC__, <= 2)

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 acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk