Falk Hueffner wrote: <snip> > > struct PACKET_HEADER > > { > > le length; > > MD5Hash setid; > > } __attribute__ ((packed)); > > > > struct MAINPACKET > > { > > PACKET_HEADER header; > > MD5Hash fileid[0]; > > } __attribute__ ((packed)); > > > > const MD5Hash& FileId(const char *packetdata, int filenumber) > > { > > return ((const MAINPACKET*)packetdata)->fileid[filenumber]; > > } > > > > const MD5Hash& SetId(const char *packetdata) > > { > > return ((const MAINPACKET*)packetdata)->header.setid; > > } > > > > // END > > > > SetId provokes the error; FileId doesn't. > > The problem is that the packedness of MAINPACKET::header isn't > ignored. > > Note also that the program will not work as intended, because (as soon > as gcc is fixed) all the packedness is ignored. So I clone this bug.
Thanks for the confirmation. Personally I think packed structures are a horrible idea. Presumably if all the classes involved are changed to be POD, they'll become packed again? (In practice I don't think it makes a difference, as the class members appear to be naturally aligned without any need for padding bytes.) Ben. -- Ben Hutchings One of the nice things about standards is that there are so many of them.
signature.asc
Description: This is a digitally signed message part