[Boost.Array] gcc 4.1.2 vs. boost alignment

I've just upgraded my compiler to gcc 4.1.2 and tried the latest
implementation of tr1 included with gcc. I've discovered the gcc
array implementation is not what I expect:
#include

On Dec 18, 2006, at 5:03 PM, Robert Mecklenburg wrote:
I've just upgraded my compiler to gcc 4.1.2 and tried the latest implementation of tr1 included with gcc. I've discovered the gcc array implementation is not what I expect: [snip code] That is, the boost array is exactly the size I require 6 bytes, but the tr1 array is larger, 16 bytes. I believe this is due to the following declaration in 4.1.2/tr1/array:
// Support for zero-sized arrays mandatory. value_type _M_instance[_Nm ? _Nm : 1] __attribute__ ((__aligned__));
The boost version is not aligned, but the gcc version is. Does the tr1 implementation require the alignment? If so, it appears that tr1::array is definitely not a suitable wrapper for C-style arrays since they aren't the same size!
Ick. I would report this to GCC as a bug. Cheers, Doug

Robert Mecklenburg napisał(a):
int main(int , char **) { boost::array
barray; std::cout << sizeof(barray) << std::endl; std::tr1::array tr1array; std::cout << sizeof(tr1array) << std::endl; } When run this code produces:
g++ foo.cpp && ./a.out 6 16
That is, the boost array is exactly the size I require 6 bytes, but the tr1 array is larger, 16 bytes.
the array is fine, just check the size() and use data().
implementation details are not our business.
$ cat test.cpp
#include
participants (3)
-
Douglas Gregor
-
Paweł Sikora
-
Robert Mecklenburg