thejohnfreeman / autocheck

Header-only C++17 library for property-based testing.
ISC License
125 stars 17 forks source link

vs2013: fix leak, vs2015+: use unrestricted union #14

Closed Meteorite closed 5 years ago

Meteorite commented 5 years ago

As unrestricted unions are not used for Visual Studio 2013, default

T  object;

field is created in value template class default contructor. But as allocation is initialized with None this default object leaks, when we start to generate test values. So, for example, there is a memory leak in the following code, if it is compiled by Visual Studio 2013:

autocheck::check<std::string>([](const std::string& str) { return true; });

Patch fixes this leakage and turns on unrestricted union usage for Visual Studio 2015+.

thejohnfreeman commented 5 years ago

Thanks for the contribution!