This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: C PATCH for c/52085 (enum forward declarations and attribute packed)
- From: Marek Polacek <polacek at redhat dot com>
- To: Jeff Law <law at redhat dot com>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>, Joseph Myers <joseph at codesourcery dot com>
- Date: Fri, 24 Apr 2015 13:36:33 +0200
- Subject: Re: C PATCH for c/52085 (enum forward declarations and attribute packed)
- Authentication-results: sourceware.org; auth=none
- References: <20150423204616 dot GG2813 at redhat dot com> <5539A9AF dot 20509 at redhat dot com>
On Thu, Apr 23, 2015 at 08:25:51PM -0600, Jeff Law wrote:
> What happens if we have used the enum inside an aggregate? Can we just
> blindly change the alignment/precision like that?
If you just forward declare an enum/struct, it has an incomplete type, so you
cannot use it inside an aggregate. In fact, you can't do much with that until
it's completed, except creating a pointer to it. E.g. applying sizeof to an
incomplete type is forbidden. With my patch, we behave the same as clang.
Marek