Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Future issue with Visual C++ 2019 Update 1 #1065

Open
JonCavesMSFT opened this issue Mar 4, 2019 · 0 comments
Open

Future issue with Visual C++ 2019 Update 1 #1065

JonCavesMSFT opened this issue Mar 4, 2019 · 0 comments

Comments

@JonCavesMSFT
Copy link

Hi: Visual C++ 2019 Update 1 (which should be released later this year) has a completely rewritten lambda parser and one side-effect of this rewrite is that the format of the names of generated closure classes has changed (the generated name is now more similar to what gcc and clang would produce). In our internal testing of this release we have found that one of your tests is failing - specifically the first line of this test:

TEST_F(AutowiringDebugTest, IsLambdaTest) {
  auto fn = [] {};
  ASSERT_TRUE(autowiring::dbg::IsLambda(typeid(fn))) << "Lambda function not correctly detected";
  ASSERT_FALSE(autowiring::dbg::IsLambda(typeid(CoreThread))) << "Simple class incorrectly identified as a lambda function";
  ASSERT_FALSE(autowiring::dbg::IsLambda(typeid(std::vector<int>))) << "Template class incorrectly identified as a lambda function";
}

The test fails because of the code below which will not work in 2019 U1 because of the change to the generated name of the closure class:

#ifdef _MSC_VER
// On Windows, lambda functions start with the key string "class <"
bool autowiring::dbg::IsLambda(const std::type_info& ti) {
  return demangle(ti)[0] == '<';
}
#else

If you compiled the program below with 2019 U1:

#include <typeinfo>
#include <cstdio>

template<typename T>
void f(T&&)
{
        const auto& info = typeid(T);
        std::printf("%s\n", info.name());
}

int main()
{
        f([] {});
}

it would produce:

class `int __cdecl main(void)'::`2'::<lambda_1>

while Visual C++ 2019 (and earlier releases) would produce:

class <lambda_b70101a59c2c086aa644ada2623ed1ce>

If you have any questions feel free to contact me.

Thanks
Jonathan Caves

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant