This is an archive of the discontinued LLVM Phabricator instance.

Microsoft mangling of return type deducing functions/lambdas that return local types
AbandonedPublic

Authored by majnemer on Mar 30 2014, 6:56 AM.

Details

Reviewers
faisalv
rnk
Summary

The following code causes clang to enter into an infinite recursion on windows 7 while attempting to microsoft-mangle the following lambda's operator function type:

auto L = [] () {
   struct M {};
   return M{};
};  

auto X = L();

I have kludged together a quick and dirty patch to identify where the problem lies, so that those who understand the microsoft-mangling process better can either help me refine it - or if they prefer - modify it to make it commit-worthy and commit it.

Diff Detail

Event Timeline

faisalv added inline comments.Mar 30 2014, 7:10 AM
lib/AST/MicrosoftMangle.cpp
1557

FYI - I suspect local enums might cause such a problem too, right (what else?)

Ugh, the MS ABI is not very amenable to this sort of thing. Current versions of MSVC cannot reason about the following source let alone mangle it:

template <typename T>
auto fun(T) {
  auto L = []() {
    struct M {};
    return M{};
  };
  return L();
}
auto doit() { return fun(0); }

Heck, even GCC does strange things here:
_ZZ3funIiEDaT_ENUlvE_4_FUNEv which demangles as auto fun<int>(int)::'lambda'()::_FUN()

I'd prefer if we mangled L's type as: 'R<lambda'_{mangling_number}>::operator()() const::M

majnemer commandeered this revision.Jul 6 2014, 2:16 PM
majnemer abandoned this revision.
majnemer edited reviewers, added: faisalv; removed: majnemer.

A different fix was landed in rL205282.