Describe the bug
MSVC 2015 doesn't like strings in GENERATE (all other compilers are just fine). Produces this error:
Click to expand
220 C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\type_traits(1292): error C2440: 'return': cannot convert from 'const char [5]' to 'const char (&&)[5]' [C:\projects\cli11\build\tests\TrueFalseTest.vcxproj]
221 C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\type_traits(1292): note: You cannot bind an lvalue to an rvalue reference
222 C:\projects\cli11\build\tests\catch.hpp(3951): note: see reference to function template instantiation 'const char (&&std::move<const char(&)[5]>(_Ty) noexcept)[5]' being compiled
223 with
224 [
225 _Ty=const char (&)[5]
226 ]
227 C:\projects\cli11\build\tests\catch.hpp(3951): note: while compiling class template member function 'Catch::Generators::SingleValueGenerator<T>::SingleValueGenerator(T)'
228 with
229 [
230 T=const char (&)[5]
231 ]
232 C:\projects\cli11\build\tests\catch.hpp(3931): note: see reference to function template instantiation 'Catch::Generators::SingleValueGenerator<T>::SingleValueGenerator(T)' being compiled
233 with
234 [
235 T=const char (&)[5]
236 ]
237 C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\type_traits(348): note: see reference to class template instantiation 'Catch::Generators::SingleValueGenerator<T>' being compiled
238 with
239 [
240 T=const char (&)[5]
241 ]
242 C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\memory(1339): note: see reference to class template instantiation 'std::is_convertible<Catch::Generators::SingleValueGenerator<T> *,Catch::Generators::IGenerator<T> *>' being compiled
243 with
244 [
245 T=const char (&)[5]
246 ]
247 C:\projects\cli11\build\tests\catch.hpp(4067): note: see reference to function template instantiation 'Catch::Generators::GeneratorWrapper<T> Catch::Generators::value<const char(&)[5]>(T)' being compiled
248 with
249 [
250 T=const char (&)[5]
251 ]
252 C:\projects\cli11\tests\TrueFalseTest.cpp(11): note: see reference to function template instantiation 'Catch::Generators::Generators<const char (&)[5]> Catch::Generators::makeGenerators<const char(&)[5],const char(&)[3],const char(&)[5],const char(&)[3]>(T,const char (&)[3],const char (&)[5],const char (&)[3])' being compiled
253 with
254 [
255 T=const char (&)[5]
256 ]
257
Expected behavior
Ideally, GENERATE("start", "stop") should be supported, but I'd be just as happy if this was just listed in the known problems section. An easy workaround is to provide as<std::string>{} as the first argument (admittedly, this converts the return value to std::string instead of const char*).
Reproduction steps
I don't have a Windows machine with MSVC 2015 handy, but this should do it:
TEST_CASE("Broken Generate", "") {
auto param = GENERATE("start", "stop");
}
In my code on Appveyor (haven't set up a GHA MSVC 2015 run yet for this repo), I'm actually using TEST_CASE_METHOD, though I'm assuming that doesn't change anything.
Platform information:
- OS: Windows
- Compiler+version: MSVC 2015 on Appveyor
- Catch version: 2.13.4
Additional context
Demo here on Appveyor, with a minimal change that breaks the build by removing the workaround listed above: CLIUtils/CLI11#577
Describe the bug
MSVC 2015 doesn't like strings in GENERATE (all other compilers are just fine). Produces this error:
Click to expand
Expected behavior
Ideally,
GENERATE("start", "stop")should be supported, but I'd be just as happy if this was just listed in the known problems section. An easy workaround is to provideas<std::string>{}as the first argument (admittedly, this converts the return value tostd::stringinstead ofconst char*).Reproduction steps
I don't have a Windows machine with MSVC 2015 handy, but this should do it:
In my code on Appveyor (haven't set up a GHA MSVC 2015 run yet for this repo), I'm actually using TEST_CASE_METHOD, though I'm assuming that doesn't change anything.
Platform information:
Additional context
Demo here on Appveyor, with a minimal change that breaks the build by removing the workaround listed above: CLIUtils/CLI11#577