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 c++/102295] ELF symbol sizes for variable-length objects are too small (C++)
Date: Mon, 13 Sep 2021 16:38:43 +0000	[thread overview]
Message-ID: <bug-102295-4-CJs4pdcryb@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-102295-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102295

--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Note, we have other issues, consider:
struct A
{
  float a;
  int b[];
};

int x[4];
struct A c = { 42.0f, { ++x[0], ++x[1], ++x[2], ++x[3] } };
When splitting the init into DECL_INITIAL constant initializer and runtime
initialization, the flexible array member initialization is moved completely
into runtime initialization and nothing remains in DECL_INITIAL from it.  For
initializers of fields other than flexible array members that is ok, but by
getting rid of the flex array member initializer the size emitted for the var
in assembly doesn't include the flexible array member at all.  That is worse
than having too small .size, in this case it means overwriting whatever is
after the variable.  Small .size actually isn't wrong-code...

  parent reply	other threads:[~2021-09-13 16:38 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-12 22:46 [Bug c++/102295] New: " pinskia at gcc dot gnu.org
2021-09-12 23:15 ` [Bug c++/102295] " pinskia at gcc dot gnu.org
2021-09-13 16:34 ` jakub at gcc dot gnu.org
2021-09-13 16:38 ` jakub at gcc dot gnu.org [this message]
2021-09-13 20:40 ` pinskia at gcc dot gnu.org
2021-09-14 14:57 ` cvs-commit at gcc dot gnu.org
2021-09-14 14:59 ` jakub at gcc dot gnu.org
2021-09-15 20:22 ` cvs-commit at gcc dot gnu.org
2021-09-15 23:05 ` cvs-commit at gcc dot gnu.org
2021-09-15 23:05 ` cvs-commit at gcc dot gnu.org
2021-09-16  8:50 ` jakub at gcc dot gnu.org
2022-05-10  8:20 ` cvs-commit at gcc dot gnu.org
2022-05-10  8:20 ` cvs-commit at gcc dot gnu.org
2022-05-11  6:22 ` cvs-commit at gcc dot gnu.org
2022-05-11  6:22 ` cvs-commit at gcc dot gnu.org
2022-05-11  6:36 ` 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-102295-4-CJs4pdcryb@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).