https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85171

            Bug ID: 85171
           Summary: generic lambda becomes recursive
           Product: gcc
           Version: 8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: nathan at gcc dot gnu.org
  Target Milestone: ---

Created attachment 43822
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=43822&action=edit
testcase

The attached testcase compiles without error, producing a recursive lambda.

During instanitation 'operator()' is looked up in the context of the lambda
type, and finds its synthesized template<T> lambda::operator()(T)->int member
function.

The non-generic case fails to find operator() at parse time and errors out.

If this lambda was embedded in a class with its own operator(), I think that's
the one we should be finding.

I presume the parser's saving a raw identifier for the operator () and then we
do a lookup in tsubst.  That lookup should not look in the lambda hierarchy. 
If this was a non-lambda instantiation, we'd either find operator() in the
non-dependent hierarchy, and use that at instantiation time, or we'd find
nothing and look in the enclosing namespace scopes.  The wrinkle with generic
lambdas is that there could be enclosing non-namespace scopes of course.

Reply via email to