public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "wjwray at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/55227] designated initializer for char array by string constant
Date: Sun, 24 Oct 2021 21:25:24 +0000	[thread overview]
Message-ID: <bug-55227-4-6H4xcZYP4b@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-55227-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #7 from Will Wray <wjwray at gmail dot com> ---
The patch below fixes the main issue (I think, checking)
by adding first_initializer_p to the error condition
it errors only where designators are not allowed.


diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 8a45411c995..f1210e862ca 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -6835,7 +6835,7 @@ reshape_init_r (tree type, reshape_iter *d, tree
first_initializer_p,
         array types (one value per array element).  */
       if (TREE_CODE (stripped_str_init) == STRING_CST)
        {
-         if (has_designator_problem (d, complain))
+         if (first_initializer_p && has_designator_problem (d, complain))
            return error_mark_node;
          d->cur++;
          return str_init;

  parent reply	other threads:[~2021-10-24 21:25 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-07  8:27 [Bug c++/55227] New: " pavel.v.chupin at gmail dot com
2012-11-07 22:25 ` [Bug c++/55227] " daniel.kruegler at googlemail dot com
2020-04-08 10:11 ` ensadc at mailnesia dot com
2020-06-16 11:40 ` steven.spark at gmail dot com
2021-10-24 15:54 ` wjwray at gmail dot com
2021-10-24 21:25 ` wjwray at gmail dot com [this message]
2021-10-24 21:31 ` wjwray at gmail dot com
2021-10-25 17:06 ` wjwray at gmail dot com
2021-10-25 17:44 ` wjwray at gmail dot com
2021-11-04 23:43 ` wjwray at gmail dot com
2021-11-07  0:27 ` pinskia at gcc dot gnu.org
2021-11-18  3:17 ` wjwray at gmail dot com
2021-11-18  3:21 ` wjwray at gmail dot com
2021-12-14  5:34 ` pinskia at gcc dot gnu.org
2022-01-23 22:27 ` cvs-commit 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-55227-4-6H4xcZYP4b@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).