You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This means code bases like https://github.com/trilinos/Trilinos have less chance to use Google Test for their unit testing, since their goal is to work with a code on any CPU or GPU.
The fix could be to promote ::testing::Test::TestBody as a public method. It could even be an opt-in choice (i.e. keep it private by default, and allow it to be public based on some CMake option.
Steps to reproduce the problem
Here is a minimal reproducer:
classMyClass
{
protected:voidTestBody()
{
auto my_lambda = [=] __host__ __device__ (void) -> int { return5.0; };
}
};
that would fail compiling with
test.cpp(...): error: The enclosing parent function("TestBody")for an extended __host__ __device__ lambda cannot have private or protected access within its class
What version of GoogleTest are you using?
I'm using the latest release 1.12.1.
What operating system and version are you using?
I'm on Ubuntu 22.04.
What compiler and version are you using?
I'm using nvcc from CUDA 12.0.0 in conjunction with gcc 11.3.0.
Describe the issue
When using
nvcc
(for compiling on NVidia GPUs), it is not possible to create lambdas withing the test body because::testing::Test::TestBody
isprivate
(e.g. when using the macroGTEST_TEST
). It is a restriction fromCUDA
, see https://docs.nvidia.com/cuda/cuda-c-programming-guide/#extended-lambda-restrictions.This means code bases like https://github.com/trilinos/Trilinos have less chance to use Google Test for their unit testing, since their goal is to work with a code on any CPU or GPU.
The fix could be to promote
::testing::Test::TestBody
as apublic
method. It could even be an opt-in choice (i.e. keep itprivate
by default, and allow it to bepublic
based on someCMake
option.Steps to reproduce the problem
Here is a minimal reproducer:
that would fail compiling with
What version of GoogleTest are you using?
I'm using the latest release
1.12.1
.What operating system and version are you using?
I'm on Ubuntu 22.04.
What compiler and version are you using?
I'm using
nvcc
fromCUDA 12.0.0
in conjunction withgcc 11.3.0
.What build system are you using?
cmake version 3.25.1
Proposed patch
The text was updated successfully, but these errors were encountered: