[Bug c++/17112] default operator= for struct with packed bitfield is wrong

bangerth at dealii dot org gcc-bugzilla@gcc.gnu.org
Fri Aug 20 12:50:00 GMT 2004


------- 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



More information about the Gcc-bugs mailing list