public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "nickc at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug middle-end/59719] New: Too much space allocated to unions containing variable length arrays
Date: Wed, 08 Jan 2014 12:01:00 -0000	[thread overview]
Message-ID: <bug-59719-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 59719
           Summary: Too much space allocated to unions containing variable
                    length arrays
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: nickc at gcc dot gnu.org

Created attachment 31771
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=31771&action=edit
test case to demonstrate the problem - effective on targets which use section
anchors

When gcc emits assembler directives to describe a union containing a variable
length array it tries to ensure that the end of the union is correctly aligned,
but it ends up emitting an incorrectly sized .zero pseudo-op. 

For example in the uploaded testcase, when compiled with an x86 toolchain, the
variable first_var_union is described in the assembler output as:

        .type   first_var_union, @object
        .size   first_var_union, 20
  first_var_union:
        .zero   4
        .string "12-octet-str"
        .zero   16

Note how the size of the variable is set to 20, but the actual size is
4+13+16=33 bytes.  Presumably the second .zero directive should have been
".zero 3".

This might just be a curiosity were it not for the fact that it makes any
following variables unaligned (unless the size of the union just happens to fir
into an alignment category).  Plus for targets which use section anchors (eg
aarch64, arm, ppc, mips), the computation of the offset to variables beyond the
variable length union will be based upon the expected size (20) not the real
size (33).


             reply	other threads:[~2014-01-08 12:01 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-08 12:01 nickc at gcc dot gnu.org [this message]
2014-01-08 12:44 ` [Bug middle-end/59719] " mikpelinux at gmail dot com
2014-01-09 20:09 ` jakub at gcc dot gnu.org

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-59719-4@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).