This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: structure members of packed structures


On Mon, 2003-07-14 at 21:14, Hans-Peter Nilsson wrote:
> On 14 Jul 2003, Mark Mitchell wrote:
> > > and only when used in an expression whose type also
> > > doesn't include a packed qualifier.  For example, this should
> > > remain valid and supported:
> > >
> > > struct Packed s1;
> > > struct __attribute__ ((packed)) Unpacked *p1;
> > > p1 = &s1.u;
> >
> > This makes sense too, but it is hard to implement what Nathan suggests
> > together with what you suggest.
> 
> If it's not possible, then that's an important NEWS item.
> 
> > Nathan, can we just prevent the assignment?  What if
> > comp_type_attributes checked for a mismatch here?
> 
> Not sure if you meant to restrict what I pointed out.  I didn't
> mean only assigment, but general expressions, e.g.
> 
> typedef struct __attribute__ ((packed)) Unpacked Pu;
> void f (Pu *);
> f (&s1.u);

I think we're on the same page.   The idea I had was that if
comp_type_attributes treated these two types as distinct, then any
conversions between the two would be disallowed without an explicit
cast.

With proper subtyping, one direction (from aligned to unaligned) would
be allowed implicitly, but that isn't practical at the moment.

-- 
Mark Mitchell <mark@codesourcery.com>
CodeSourcery, LLC


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]