public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "jakub at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug middle-end/28865] Structures with a flexible arrray member have wrong .size
Date: Mon, 13 Jan 2014 11:52:00 -0000	[thread overview]
Message-ID: <bug-28865-4-g6ZDK6qipz@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-28865-4@http.gcc.gnu.org/bugzilla/>

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28865

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jsm28 at gcc dot gnu.org

--- Comment #20 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
(In reply to Alan Modra from comment #19)
> Jakub, you're correct.  I should have read the standard on flexible array
> members before poking at this bug last year.  Nick's patch is looking good
> to me.
> 
> ISO/IEC 9899:1999 is quite clear that the answer to comment #2 is that
> sizeof does *not* include the flexible array component (but it does include
> any padding needed to align the start of the flexible array).  I think it is
> reasonable to do the same for .size and not include the flexible array
> component there too.

Well, sizeof is clear, but .size doesn't need to be the same thing, IMHO .size
really should be DECL_SIZE of the decl and we do adjust that for the flexible
array member in there.  If .size would be just e.g. TYPE_SIZE, then there could
be e.g. problems with copy relocations.
> 
> The testcase (which is invalid code IMO) in comment #3 hits this assert in
> varasm.c:

The #c3 is invalid, I agree, how can you have an array if each array entry has
a different size?  I mean, the C standard allows flexible array members only at
the toplevel and not initialized, as GNU extension we allow it to be
initialized and allow it even in some cases where it is not toplevel, but where
it is still reasonable (e.g. the case where it is at the end of struct which is
inside a union is reasonable, so would be placing it at the end of another
structure, but placing it in an array is IMHO something that should be rejected
by the FE).
CCing Joseph on it.


  parent reply	other threads:[~2014-01-13 11:52 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <bug-28865-4@http.gcc.gnu.org/bugzilla/>
2013-04-08 21:57 ` pinskia at gcc dot gnu.org
2013-04-08 21:57 ` pinskia at gcc dot gnu.org
2013-04-08 22:39 ` hjl.tools at gmail dot com
2013-04-20  9:54 ` schwab@linux-m68k.org
2013-05-04 14:34 ` amodra at gmail dot com
2013-05-04 14:39 ` amodra at gmail dot com
2014-01-09 20:09 ` jakub at gcc dot gnu.org
2014-01-09 20:09 ` jakub at gcc dot gnu.org
2014-01-09 20:09 ` jakub at gcc dot gnu.org
2014-01-09 20:10 ` bergner at gcc dot gnu.org
2014-01-10 16:53 ` nickc at gcc dot gnu.org
2014-01-10 22:51 ` amodra at gmail dot com
2014-01-10 23:13 ` amodra at gmail dot com
2014-01-13 11:43 ` amodra at gmail dot com
2014-01-13 11:52 ` jakub at gcc dot gnu.org [this message]
2014-01-13 16:03 ` joseph at codesourcery dot com
2014-01-13 16:47 ` jakub at gcc dot gnu.org
2014-01-13 17:47 ` nickc at gcc dot gnu.org
2014-01-14 11:58 ` amodra at gmail dot com
2014-01-16 12:18 ` nickc at gcc dot gnu.org
2014-01-16 12:19 ` nickc at gcc dot gnu.org
2006-08-27 21:53 [Bug c/28865] New: " qrczak at knm dot org dot pl
2006-08-27 22:15 ` [Bug middle-end/28865] " qrczak at knm dot org dot pl
2006-08-28  3:08 ` pinskia at gcc dot gnu dot org
2007-12-03 23:42 ` lauro dot venancio at gmail dot com

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-28865-4-g6ZDK6qipz@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).