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

Can't compile SingleValueGenerator inside GENERATE_COPY #1809

Closed
TysonRayJones opened this issue Nov 25, 2019 · 1 comment · Fixed by #1815
Closed

Can't compile SingleValueGenerator inside GENERATE_COPY #1809

TysonRayJones opened this issue Nov 25, 2019 · 1 comment · Fixed by #1815
Labels

Comments

@TysonRayJones
Copy link

Describe the bug
Attempting to invoke the SingleValueGenerator (using external variables) inside GENERATE_COPY like so...

int a = 1;
int b = 2;
int c = GENERATE_COPY( a,b );

results in a compilation error:

error: no matching function for call to 'Catch::Generators::GeneratorWrapper<const int&>::GeneratorWrapper(Catch::Generators::GeneratorWrapper<const int>)'
  { ::new((void *)__p) _Up(std::forward<_Args>(__args)...); }

Expected behavior
The above example code should compile fine, since GENERATE_COPY should allow the use of external variables (a and b) in any generator. For example, the following code compiles totally fine (using RangeGenerator):

int a = 1;
int b = 2;
int c = GENERATE_COPY( range(a,b) );

Reproduction steps
self-contained code bugdemo.cpp:

#include "catch.hpp"

TEST_CASE( "bug " ) {
    
    int a = 1;
    int b = 2;
    int c = GENERATE_COPY(a, b);
    REQUIRE( true );
}

and compiled simply with

g++ -std=c++14 -c bugdemo.cpp

Platform information:

  • OS: MacOS 10.14 and Ubuntu 18.04
  • Compiler+version: GCC v8.2.0 and GCC v7.4.0 and clang v10.0.0 (and all other versions on system)
  • Catch version: v2.10.0
Tridacnid added a commit to Tridacnid/Catch2 that referenced this issue Dec 15, 2019
…n forward was needed. Correct some missing universal references in method parameter lists. Add IntrospectiveTest to verify fix for issue catchorg#1809.
horenmar pushed a commit to Tridacnid/Catch2 that referenced this issue Dec 15, 2019
@horenmar horenmar added the Bug label Dec 15, 2019
@TysonRayJones
Copy link
Author

Lovely, thank you very much!

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

Successfully merging a pull request may close this issue.

2 participants