This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [C++ PATCH] Partially fix designated-initializer-list handling in overload resolution (PR c++/71446)


On 3/1/19 1:53 PM, Jakub Jelinek wrote:
Hi!

http://eel.is/c++draft/dcl.init.list#3.1 says that for designated
initializers only aggregate conversion should be performed,
while our current code would happily try std::initializer_list
initialization, or (as extension) complex initialization, or scalar
initialization if there is { .foobarbaz = 1 }.

Unfortunately, e.g. reshape_init seems to add ce->index values, so checking
whether ce->index is NULL for all elements of the CONSTRUCTOR doesn't seem
to work.

This patch instead remembers in a bit on the CONSTRUCTOR whether there
were any user designators.  Bootstrapped/regtested on x86_64-linux and
i686-linux, ok for trunk?

OK, thanks.

Note, this is just a partial fix for the PR, for the second part (making
struct S { void *a; int b; };
void foo (S);
... foo ({.b = 1}) work), I'm afraid I don't really understand what the C++
standard wants to say in http://eel.is/c++draft/over.ics.list#2 and what
build_aggr_conv should do, such that the cpp2a/desig{4,6}.C testcases taken
from the standard as well as the desig11.C in the earlier version of the
patch (would need to be renamed to desig12.C) can pass.

It seems to me that for designated initializers, we should make sure that all the designators match fields, and otherwise check convertibility like build_aggr_conv already does.

Jason


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]