public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "krzysztof.a.nowicki+gcc at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c/95052] Excess padding of partially initialized strings/char arrays
Date: Mon, 11 May 2020 13:07:04 +0000	[thread overview]
Message-ID: <bug-95052-4-vtkKjVlten@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-95052-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #2 from Krzysztof Nowicki <krzysztof.a.nowicki+gcc at gmail dot com> ---
(In reply to Richard Biener from comment #1)
> I'm not sure what you describe as padding is padding.  Instead it's valid to
> access all elements of the array you declare and thus it must be initialized.

Not in this case, as this is a constant initializer, which is anonymous and is
never accessible from the code directly.

> What could be done is elide zero-padding parts to a memset() call.

Exactly, this is what I mean. Currently this actually happens in the generated
code (see attachment), but the part of GCC which allocates the variable in the
.rodata section doesn't know that and allocates memory for the full contents
including the zero padding.

  parent reply	other threads:[~2020-05-11 13:07 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-11 10:50 [Bug c/95052] New: " krzysztof.a.nowicki+gcc at gmail dot com
2020-05-11 11:32 ` [Bug c/95052] " rguenth at gcc dot gnu.org
2020-05-11 13:07 ` krzysztof.a.nowicki+gcc at gmail dot com [this message]
2020-05-11 13:18 ` krzysztof.a.nowicki+gcc at gmail dot com
2020-05-11 14:41 ` [Bug target/95052] " msebor at gcc dot gnu.org
2020-05-11 14:51 ` krzysztof.a.nowicki+gcc at gmail dot com
2020-05-11 19:06 ` [Bug middle-end/95052] " jakub at gcc dot gnu.org
2020-05-13  5:05 ` krzysztof.a.nowicki+gcc at gmail dot com
2020-05-13 12:33 ` [Bug middle-end/95052] [9/10/11 Regression] " pinskia at gcc dot gnu.org
2020-05-29  8:43 ` cvs-commit at gcc dot gnu.org
2020-05-29 13:27 ` mkuvyrkov at gcc dot gnu.org
2020-05-29 14:22 ` mkuvyrkov at gcc dot gnu.org
2020-05-29 14:26 ` mkuvyrkov at gcc dot gnu.org
2020-05-29 19:37 ` jakub at gcc dot gnu.org
2020-05-31  9:55 ` cvs-commit at gcc dot gnu.org
2020-08-03 11:10 ` ptsneves at gmail dot com
2021-01-14  8:46 ` [Bug middle-end/95052] [9/10 " rguenth at gcc dot gnu.org
2021-06-01  8:17 ` rguenth at gcc dot gnu.org
2022-05-27  9:42 ` [Bug middle-end/95052] [10 " rguenth at gcc dot gnu.org
2022-06-28 10:40 ` jakub at gcc dot gnu.org
2023-07-07  8:52 ` rguenth 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-95052-4-vtkKjVlten@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).