[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Bug in gcc?
- Date: Thu, 05 Jun 2008 17:37:17 +0100
- From: timcussins at eml.cc (Tim Cussins)
- Subject: Bug in gcc?
Leon Pollak wrote:
> Hello, all.
>
> It seems to me I found a bug in gcc, but as it is rtems-provided cross-gcc, I
> think it was better to ask here first.
>
> I have the following code:
> template <class TYPE> class sCmnd2DSPs {
> public:
> enum eSources {eDiscr=0, eRS1, eRS2,
> eMB1, eMB2, eEth1, eEth2} __attribute__ ((packed));
> struct {
> eSources Source;
> uchar Addr;
> eCmndCodesDSPs Opcode;
> TYPE Params; } __attribute__ ((packed));
> ...............
> };
>
> Everything works fine, but the field Source in the code above occupies 4
> bytes, despite the packed request.
>
> Now, if I take the enumeration declaration out of the class (put it above the
> class declaration), then the Source field occupies 1 byte as required.
>
> Should I report this to gcc list?
>
> Thanks.
Before you do that you might want to check how it behaves on a normal
*nix machine - and also maybe have a look at how it behaves for a normal
(non-templated) class.
btw - if the enum is common to all classes based on that template, maybe
it should be outside the template definition anyway ;P
Tim