This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: structure members of packed structures
- From: Mark Mitchell <mark at codesourcery dot com>
- To: Hans-Peter Nilsson <hp at bitrange dot com>
- Cc: Nathan Sidwell <nathan at codesourcery dot com>, gcc at gcc dot gnu dot org
- Date: 14 Jul 2003 22:40:30 -0700
- Subject: Re: structure members of packed structures
- Organization: CodeSourcery, LLC
- References: <Pine.BSF.4.44.0307150002220.96500-100000@dair.pair.com>
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