------- Additional Comments From yanliu at ca dot ibm dot com 2005-01-14 20:10 ------- You are right, I was using linux and darwin two different compilers. In thse two situations, the gcc results are both right.
I have another question for you for the same testcase: if initializing the bitfield with 1, and the bitwidth=17. I got two different layouts for the bitfield member with different g++ compilers: Both compilers are ppc-rhat. One is 3.4.3, the other is 3.2.3. Here is the first compiler's info: Reading specs from /usr/lib/gcc/ppc64-redhat-linux/3.4.3/specs Configured with: ../configure --prefix=/usr --mandir=/usr/share/man -- infodir=/usr/share/info --enable-shared --enable-threads=posix --disable- checking --with-system-zlib --enable-__cxa_atexit --disable-libunwind- exceptions --enable-languages=c,c++,objc,java,f77 --enable-java-awt=gtk -- host=ppc64-redhat-linux --build=ppc64-redhat-linux --target=ppc64-redhat-linux - -with-cpu=default32 Thread model: posix gcc version 3.4.3 20041125 (Red Hat 3.4.3-6.EL4) Running the testcase, here is what I got: with g++3.2.3, the result is: Dumping array with size of 4 Character 0 is 0 Character 1 is 1 Character 2 is 0 Character 3 is 0 c1.m1=1, With 3.4.3 g++ compiler, the result is: Dumping array with size of 4 Character 0 is 1 Character 1 is 0 Character 2 is 0 Character 3 is 0 c1.m1=1, The Itanium C++ ABI didn't specify how to layout bitfield member if their width exceeds its type. Did you put your least-important bit at the left hand side? Could you tell me your algorithm on the bitfield member layout? Thanks. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19448