(This is a follow-up to a question I posted a few hours ago, then deleted. I now have a minimal reproducible example in about 10 lines)
The following code will cause an access violation with MSVC, but works perfectly with gcc and clang.
#include <map>
//template <typename T> auto inner = []()
template <typename T> void inner()
{
std::map<int, int> x;
x.clear(); // Will cause an access violation
};
//template <typename T> auto outer = []()
template <typename T> void outer()
{
inner<T>();
};
int main()
{
outer<int>();
}
See on compiler explorer: https://godbolt.org/z/qPxr3EGf5
If you uncomment the lines where I replace the generic lambdas with standard generic functions, everything works fine.
Am I doing something terribly wrong?