gcc 4.7.0 20110521 (experimental) in C++0x mode rejects the following code: //--- struct A { const int m; }; A a1 = {}; // #1 A a2{}; // #2 //--- The error messages at the lines marked with #1 and #2 are: "error: uninitialized const member 'A::m'" The code should be accepted, because the objects undergo aggregate-initialization. The error message is incorrect, the objects are initialized.
Yes. process_init_constructor_record shouldn't complain about uninitialized const members, because within aggregate initialization, members without explicit initializers are value-initialized. Fabien?
It's annoying how GCC bugzilla tends not to send mail to people when I add them to CC even if I also add a comment. Anyway, Fabien, please take a look at this bug.
This is a regression relative to 4.5 in C++98/03 mode as well (the a1 declaration).
Actually it isn't a regression, it's broken as far back as 2.95.
This was clarified to be well-formed as part of DR 178. http://www.open-std.org/JTC1/SC22/WG21/docs/cwg_defects.html#178
(In reply to comment #2) > It's annoying how GCC bugzilla tends not to send mail to people when I add them > to CC even if I also add a comment. Anyway, Fabien, please take a look at this > bug. GCC bugzilla mails seem to go out in random order with arbitrarily long delays recently, so the "New" bug mail sometimes appears in the archives several minutes after the first comment on a bug. very annoying
Mine.
Author: paolo Date: Wed Jun 25 14:27:35 2014 New Revision: 211981 URL: https://gcc.gnu.org/viewcvs?rev=211981&root=gcc&view=rev Log: /cp 2014-06-25 Paolo Carlini <paolo.carlini@oracle.com> DR 178 PR c++/49132 * typeck2.c (process_init_constructor_record): Do not complain about uninitialized const members, because within aggregate-initialization, members without explicit initializers are value-initialized. /testsuite 2014-06-25 Paolo Carlini <paolo.carlini@oracle.com> DR 178 PR c++/49132 * g++.dg/cpp0x/aggr1.C: New. * g++.dg/cpp0x/aggr2.C: Likewise. * g++.dg/init/aggr11.C: Likewise. * g++.dg/init/aggr12.C: Likewise. Added: trunk/gcc/testsuite/g++.dg/cpp0x/aggr1.C trunk/gcc/testsuite/g++.dg/cpp0x/aggr2.C trunk/gcc/testsuite/g++.dg/init/aggr11.C trunk/gcc/testsuite/g++.dg/init/aggr12.C Modified: trunk/gcc/cp/ChangeLog trunk/gcc/cp/typeck2.c trunk/gcc/testsuite/ChangeLog
Fixed for 4.10.0.
*** Bug 61581 has been marked as a duplicate of this bug. ***