On Tue, May 03, 2022 at 04:43:05PM -0400, Jason Merrill via Gcc-patches wrote: > On 5/2/22 12:18, Marek Polacek wrote: > > Consider > > > > struct F { > > F(int) {} > > F operator()(int) const { return *this; } > > }; > > > > and > > > > F(i)(0)(0); > > > > where we're supposed to first call the constructor and then invoke > > the operator() twice. However, we parse this as an init-declarator: > > "(i)" looks like a perfectly valid declarator, then we see an '(' and > > think it must be an initializer, so we commit and we're toast. > > How vexing!
:-) Most vexing indeed! > > My > > fix is to look a little bit farther before deciding we've seen an > > initializer. > > > > This is only a half of c++/64679, the other part of the PR is unrelated: > > there the problem is that we are calling pushdecl while parsing > > tentatively (in cp_parser_parameter_declaration_list), which is bad. > > I don't know how to fix it though, maybe move the pushdecl call to > > grokparms? Tricky :(. > > Can we pop the parm decls when the tentative parse fails? Unfortunately no, we'll have already given a hard error when that happens. About to send a patch where I describe the problem in detail. > > Bootstrapped/regtested on x86_64-pc-linux-gnu, ok for trunk? > > OK. Thanks! Marek