Hi,
On 09/11/2015 10:05 PM, Jason Merrill wrote:
On 09/11/2015 03:11 PM, Paolo Carlini wrote:
this is a slightly reworked (simplified) version of a patch I sent a
while ago. The issue is that we are not enforcing at all 5.3.4/2 in the
parser, thus we end up rejecting the first test below with a misleading
error message talking about list-initialization (and a wrong location),
because we diagnose it too late like 'auto foo{3, 4, 5};', and simply
accepting the second. Tested x86_64-linux.
Hmm, I think we really ought to accept
new auto { 2 }
to be consistent with all the other recent changes to treat { elt }
like (elt); this seems like a piece that was missed from DR 1467. Do
you agree, Ville?
I see, while waiting for Ville, maybe I can ask what we should do in
case he agrees. The error message we currently emit for new auto { 3, 4,
5 } seems suboptimal in various ways:
51911.C:6:31: error: direct-list-initialization of ‘auto’ requires
exactly one element [-fpermissive]
auto foo = new auto { 3, 4, 5 };
^
51911.C:6:31: note: for deduction to ‘std::initializer_list’, use
copy-list-initialization (i.e. add ‘=’ before the ‘{’)
the caret is under the last '}' and the note doesn't make much sense (of
course do_auto_deduction doesn't know we are handling a new). Thus I
wonder if we should anyway have something in the parser and with which
exact wording (just tweak what I sent earlier replacing 'exactly one
parenthesized expression' with 'exactly one element'?!?)
Thanks,
Paolo.