public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Paolo Carlini <paolo.carlini@oracle.com>
To: Jason Merrill <jason@redhat.com>
Cc: "gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>
Subject: Re: [C++ Patch] PR 54501
Date: Thu, 18 Oct 2012 09:17:00 -0000	[thread overview]
Message-ID: <507FBABB.5090308@oracle.com> (raw)
In-Reply-To: <507F589F.3060609@redhat.com>

Hi,

On 10/18/2012 03:17 AM, Jason Merrill wrote:
> Hmm, I thought I fixed a very similar bug recently.
>
> I'm concerned that this change will cause problems with brace-elision 
> situations.  But then again, can we have a zero-length array followed 
> by anything else?
If I understand correctly your hesitations, I don't think there are 
exceptions to the general rule that if the size of the array is zero 
there can be no initializers. This morning I investigated in some detail 
this special case (from a testcase I recently added, pr43765.C):

struct SomeType
{
   const char *values[];
};

it's in fact related because we parse it as:

struct SomeType
{
   const char *values[0];
};

(per grokdeclarator around line 10246). Given the way we parse it (not 
completely uncontroversial, IMHO, but that would be a separate issue), 
we do the right thing, we accept:

SomeType s = { };

and we reject:

SomeType s = { 1 };

Only the wording of the error changes (from "too many initializers" to 
"initializers provided") (*)

In any case, I can't imagine a different, safer, way to handle the issue 
we are facing. Do you have anything specific to suggest?

Thanks,
Paolo.

(*) Moreover we likewise accept:

SomeType s = { {  } };

and likewise reject:

SomeType s = { { { } } };

  reply	other threads:[~2012-10-18  8:16 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-17 17:01 Paolo Carlini
2012-10-17 17:27 ` Paolo Carlini
2012-10-18  3:06   ` Jason Merrill
2012-10-18  9:17     ` Paolo Carlini [this message]
2012-10-18 16:21       ` Jason Merrill
2012-10-18 17:40         ` Paolo Carlini
2012-10-18 19:32         ` Paolo Carlini
2012-10-18 23:07           ` Jason Merrill

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=507FBABB.5090308@oracle.com \
    --to=paolo.carlini@oracle.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jason@redhat.com \
    /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).