While implementing return type deduction for generic lambdas, I stumbled upon
a bug which led to clang mishandling the following code:

struct Lambda {
  template<class T> auto operator()(T t) {
    return 5;
  }
template<class T> auto foo(T t) { return t; }
};
void test() {
    Lambda L;
    int i = L(3);
}


The issue (as i understand it) was that in some contexts only the
function template (and not the specialization) would get passed to
DiagnoseUseOfDecl (which deduces the return type of the function).  So
the specialization would flow through to Codegen with auto as its
return type.

So, with that in mind, this patch implements a trivial fix.

What do you think Richard? Is there a better way to address this bug?
Are there other places
this could happen (ie. template conversion operator?)

Thanks!
Faisal Vali

Attachment: fix-return-type-deduction-for-member-templates.patch
Description: Binary data

_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to