On 08/01/2014 08:51 PM, Jason Merrill wrote:
...and for array initialization as well.
Small tweak: we don't need to mess with empty_list if we don't have any trailing elements to initialize.
commit 44aef29c18bfd087d9b7bd72699bad9c72e272fb Author: Jason Merrill <ja...@redhat.com> Date: Wed Aug 6 15:22:44 2014 -0400 PR c++/60417 * init.c (build_vec_init): Reorganize earlier change a bit. diff --git a/gcc/cp/init.c b/gcc/cp/init.c index 17e6c4b..777e0a9 100644 --- a/gcc/cp/init.c +++ b/gcc/cp/init.c @@ -3685,26 +3685,6 @@ build_vec_init (tree base, tree maxindex, tree init, } } - /* If the initializer is {}, then all elements are initialized from T{}. - But for non-classes, that's the same as value-initialization. */ - if (empty_list) - { - if (cxx_dialect >= cxx11 && AGGREGATE_TYPE_P (type)) - { - if (BRACE_ENCLOSED_INITIALIZER_P (init) - && CONSTRUCTOR_NELTS (init) == 0) - /* Reuse it. */; - else - init = build_constructor (init_list_type_node, NULL); - CONSTRUCTOR_IS_DIRECT_INIT (init) = true; - } - else - { - init = NULL_TREE; - explicit_value_init_p = true; - } - } - /* Now, default-initialize any remaining elements. We don't need to do that if a) the type does not need constructing, or b) we've already initialized all the elements. @@ -3736,6 +3716,26 @@ build_vec_init (tree base, tree maxindex, tree init, to = build1 (INDIRECT_REF, type, base); + /* If the initializer is {}, then all elements are initialized from T{}. + But for non-classes, that's the same as value-initialization. */ + if (empty_list) + { + if (cxx_dialect >= cxx11 && AGGREGATE_TYPE_P (type)) + { + if (BRACE_ENCLOSED_INITIALIZER_P (init) + && CONSTRUCTOR_NELTS (init) == 0) + /* Reuse it. */; + else + init = build_constructor (init_list_type_node, NULL); + CONSTRUCTOR_IS_DIRECT_INIT (init) = true; + } + else + { + init = NULL_TREE; + explicit_value_init_p = true; + } + } + if (from_array) { tree from;