Skip to content

Templated lambda ends up with dependent type in C++11 #113792

@tbaederr

Description

@tbaederr

This is an issue for the bug from #108598

This code:

template<typename T>
constexpr T outer() {
  return []<T x>() { return x; }.template operator()<123>();
}
static_assert(outer<int>() == 123);

ends up with a dependent type that we assert on in codegen.

This starts when we deduce the type of the call operator, which is dependent in C++11 but auto in later versions:

case DeclSpec::TST_unspecified:
// If this is a missing declspec in a block literal return context, then it
// is inferred from the return statements inside the block.
// The declspec is always missing in a lambda expr context; it is either
// specified with a trailing return type or inferred.
if (S.getLangOpts().CPlusPlus14 &&
declarator.getContext() == DeclaratorContext::LambdaExpr) {
// In C++1y, a lambda's implicit return type is 'auto'.
Result = Context.getAutoDeductType();
break;
} else if (declarator.getContext() == DeclaratorContext::LambdaExpr ||
checkOmittedBlockReturnType(S, declarator,
Context.DependentTy)) {
Result = Context.DependentTy;
break;
}

and we never seem to clean this up.

Metadata

Metadata

Assignees

Labels

clang:frontendLanguage frontend issues, e.g. anything involving "Sema"lambdaC++11 lambda expressions

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions