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

google-test subdirectory fails to build (-Werror) #10

Closed
telans opened this issue Jun 27, 2023 · 1 comment
Closed

google-test subdirectory fails to build (-Werror) #10

telans opened this issue Jun 27, 2023 · 1 comment

Comments

@telans
Copy link

telans commented Jun 27, 2023

In attempting Task 2/14, compilation fails when checking the answer as google-test fails to build due to -Werror=maybe-uninitialized:

====================[ Build | WarmUp-MovingOn-MoveAnObject-test | Debug ]=======
/home/telans/.local/share/JetBrains/Toolbox/apps/clion/bin/cmake/linux/x64/bin/cmake --build /home/telans/CLionProjects/C++Basics/cmake-build-debug --target WarmUp-MovingOn-MoveAnObject-test -- -j 14
[ 16%] Built target WarmUp-MovingOn-MoveAnObject-test-src-part
[ 33%] Building CXX object /home/telans/CLionProjects/C++Basics/test-framework/googletest-build/googlemock/gtest/CMakeFiles/gtest.dir/src/gtest-all.cc.o
In file included from /home/telans/CLionProjects/C++Basics/test-framework/googletest-src/googletest/src/gtest-all.cc:42:
/home/telans/CLionProjects/C++Basics/test-framework/googletest-src/googletest/src/gtest-death-test.cc: In function ‘bool testing::internal::StackGrowsDown()’:
/home/telans/CLionProjects/C++Basics/test-framework/googletest-src/googletest/src/gtest-death-test.cc:1224:24: error: ‘dummy’ may be used uninitialized [-Werror=maybe-uninitialized]
 1224 |   StackLowerThanAddress(&dummy, &result);
      |   ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
/home/telans/CLionProjects/C++Basics/test-framework/googletest-src/googletest/src/gtest-death-test.cc:1214:13: note: by argument 1 of type ‘const void*’ to ‘void testing::internal::StackLowerThanAddress(const void*, bool*)’ declared here
 1214 | static void StackLowerThanAddress(const void* ptr, bool* result) {
      |             ^~~~~~~~~~~~~~~~~~~~~
/home/telans/CLionProjects/C++Basics/test-framework/googletest-src/googletest/src/gtest-death-test.cc:1222:7: note: ‘dummy’ declared here
 1222 |   int dummy;
      |       ^~~~~
cc1plus: all warnings being treated as errors
make[3]: *** [/home/telans/CLionProjects/C++Basics/test-framework/googletest-build/googlemock/gtest/CMakeFiles/gtest.dir/build.make:76: /home/telans/CLionProjects/C++Basics/test-framework/googletest-build/googlemock/gtest/CMakeFiles/gtest.dir/src/gtest-all.cc.o] Error 1
make[2]: *** [CMakeFiles/Makefile2:1045: /home/telans/CLionProjects/C++Basics/test-framework/googletest-build/googlemock/gtest/CMakeFiles/gtest.dir/all] Error 2
make[1]: *** [CMakeFiles/Makefile2:2658: WarmUp/MovingOn/task/CMakeFiles/WarmUp-MovingOn-MoveAnObject-test.dir/rule] Error 2
make: *** [Makefile:988: WarmUp-MovingOn-MoveAnObject-test] Error 2

This is due to google-test < 1.11.0 failing to cleanly build with GCC >= 11.
See google/googletest#3219

This could be fixed by passing -Wno-error to cmake, patching the subdirectory with the closing commit on the issue linked above, or updating the google-test version.

Manually updating cmake/googletest-download.cmake to add release-1.11.0 fixes this issue for me.

@eupp
Copy link
Collaborator

eupp commented Jun 27, 2023

Hi, thank you for the report.
It is a known problem.
The fix is already implemented, and the course will be soon updated on the Marketplace.

@telans telans closed this as completed Jun 27, 2023
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

2 participants