This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/17112] default operator= for struct with packed bitfield is wrong
- From: "bangerth at dealii dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 20 Aug 2004 12:50:40 -0000
- Subject: [Bug c++/17112] default operator= for struct with packed bitfield is wrong
- References: <20040819232250.17112.gene@digilicious.com>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Additional Comments From bangerth at dealii dot org 2004-08-20 12:50 -------
To see what really happens, here's a way to get a dump of the
contents of the entire field:
------------------
#include <iostream>
using namespace std;
struct myint24 {
int int24:24 __attribute__ ((packed));
};
myint24 x[3] = {
0x010203,
0x040506,
0x070809
};
myint24 y[3]; // starts out as zeros
int main(int ac, char* av[])
{
y[1] = x[1];
for ( int i=0; i<sizeof(y); ++i )
cout << (int)*((char*)y + i) << endl;
}
--------------------------
This, for me, prints
g/x> ./a.out
0
0
0
6
5
4
9
0
0
W.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17112