public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "hstong at ca dot ibm.com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/64696] New: [C++14] braced-init-list does not cause expected aggregate initialization
Date: Tue, 20 Jan 2015 18:38:00 -0000	[thread overview]
Message-ID: <bug-64696-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 64696
           Summary: [C++14] braced-init-list does not cause expected
                    aggregate initialization
           Product: gcc
           Version: 5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: hstong at ca dot ibm.com

In the test case below, C++14 specifies that aggregate initialization is
performed in subclause 8.5.4 [dcl.init.list] paragraph 3 for the braced-init-
list containing "DESIGNATOR" in the source.

Said aggregate initialization should leave the "x" member of the temporary with
a value of 2.

GCC does not appear to understand this to be the case since the static_assert
should evaluate to false but no diagnostic appears.

If the resolution of Core Issue 1467 is taken into account, then the case with
of -std=gnu++1y -DDESIGNATED still behaves similarly. This result is rather
surprising since the natural interpretation of that designated initializer is
that it applies directly to the "a" member.


### SOURCE (<stdin>):
struct A {
   const A &a; int x = 2;
};

extern A a0;

#if DESIGNATED
# define DESIGNATOR .a =
#else
# define DESIGNATOR
#endif
constexpr int x = A{ DESIGNATOR A{ a0, 4 } }.x;

static_assert(x != 2, "Expected diagnostic");

int main() { }


### COMPILER INVOCATION:
g++ -Wall -Wextra -pedantic -std=c++1y -x c++ -


### COMPILER OUTPUT:
No text; RC=0


### EXPECTED OUTPUT:
<stdin>:14:1: error: static assertion failed: Expected diagnostic


### VERSION INFO:
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/local/gcc-head/libexec/gcc/x86_64-unknown-linux-gnu/5.0.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: /home/heads/gcc/gcc-source/configure
--prefix=/usr/local/gcc-head --enable-languages=c,c++ --enable-lto
--disable-multilib --without-ppl --without-cloog-ppl --enable-checking=release
--disable-nls
Thread model: posix
gcc version 5.0.0 20150120 (experimental) (GCC)


             reply	other threads:[~2015-01-20 18:38 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-20 18:38 hstong at ca dot ibm.com [this message]
2021-07-28  5:06 ` [Bug c++/64696] [C++14] braced-init-list does not respect designated initializer pinskia at gcc dot gnu.org
2024-03-12  7:09 ` pinskia 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-64696-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).