[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#356548: Processed: probably a compiler bug



clone 356548 -1
reassign -1 par2cmdline
tags 356548 + upstream
forwarded 356548 http://gcc.gnu.org/PR26670
thanks

Ben Hutchings <ben@decadentplace.org.uk> writes:

> Martin Michlmayr wrote:
>> I don't understand the problem.  Ben (CCed) made a suggestion, but
>> afaik he hasn't been able yet to come up with a simple test case.
>
> I have now, and it isn't MIPS-specific:
>
> class le
> {
> protected:
>   int value;
> };
>
> struct MD5Hash
> {
>   MD5Hash(const MD5Hash &);
>   char hash[16];
> };
>
> 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.

-- 
	Falk



Reply to: