This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
RFA: C++ PATCH for c++/37740
- From: Jason Merrill <jason at redhat dot com>
- To: gcc-patches List <gcc-patches at gcc dot gnu dot org>
- Date: Fri, 14 Nov 2008 15:00:50 -0500
- Subject: RFA: C++ PATCH for c++/37740
This patch is a trivial fix for a bug in a new feature, so I'd like to
get it into 4.4; I think that bugfixes for new functionality should be
allowed in the final stage along with regression fixes, but I'm not a
release manager.
The problem was that in considering whether or not we could convert an
init-list to an aggregate class, I was comparing all the first element
of the list to all the fields, which doesn't work too well...
Tested x86_64-pc-linux-gnu.
2008-11-14 Jason Merrill <jason@redhat.com>
PR c++/37740
* call.c (build_aggr_conv): Increment i.
* g++.dg/cpp0x/initlist8.C: New test.
Index: cp/call.c
===================================================================
*** cp/call.c (revision 141842)
--- cp/call.c (working copy)
*************** build_aggr_conv (tree type, tree ctor, i
*** 619,625 ****
conversion *c;
tree field = TYPE_FIELDS (type);
! for (; field; field = TREE_CHAIN (field))
{
if (TREE_CODE (field) != FIELD_DECL)
continue;
--- 619,625 ----
conversion *c;
tree field = TYPE_FIELDS (type);
! for (; field; field = TREE_CHAIN (field), ++i)
{
if (TREE_CODE (field) != FIELD_DECL)
continue;
Index: testsuite/g++.dg/cpp0x/initlist8.C
===================================================================
*** testsuite/g++.dg/cpp0x/initlist8.C (revision 0)
--- testsuite/g++.dg/cpp0x/initlist8.C (revision 0)
***************
*** 0 ****
--- 1,19 ----
+ // PR c++/37740
+ // { dg-options "-std=c++0x" }
+
+ struct A
+ {
+ int i;
+ };
+
+ struct B
+ {
+ double d;
+ A i;
+ };
+
+ int main()
+ {
+ A a;
+ new B{3.2, a};
+ }