Gergő Szabó
Gergő Szabó

Reputation: 57

'dummy' may be used uninitialized

I have an issue running a clion project stepik file. The following error keeps showing up. I have a compiler and I can run other codes, but some doesn't work.

In file included from /home/gergoszabo/CLionProjects/Prog2_08/test-framework/googletest-src/googletest/src/gtest-all.cc:42:
/home/gergoszabo/CLionProjects/Prog2_08/test-framework/googletest-src/googletest/src/gtest-death-test.cc: In function ‘bool testing::internal::StackGrowsDown()’:
/home/gergoszabo/CLionProjects/Prog2_08/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/gergoszabo/CLionProjects/Prog2_08/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/gergoszabo/CLionProjects/Prog2_08/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
gmake[3]: *** [../test-framework/googletest-build/googlemock/gtest/CMakeFiles/gtest.dir/build.make:72: ../test-framework/googletest-build/googlemock/gtest/CMakeFiles/gtest.dir/src/gtest-all.cc.o] Error 1
gmake[2]: *** [CMakeFiles/Makefile2:587: ../test-framework/googletest-build/googlemock/gtest/CMakeFiles/gtest.dir/all] Error 2
gmake[1]: *** [CMakeFiles/Makefile2:1394: lesson1/labbeli/CMakeFiles/global-lesson1-labbeli-test.dir/rule] Error 2
gmake: *** [Makefile:598: global-lesson1-labbeli-test] Error 2

Upvotes: 4

Views: 7728

Answers (1)

Ghostkeeper
Ghostkeeper

Reputation: 3050

This problem is not in your own project, but in a library it seems to be using: GoogleTest.

The version of GoogleTest you're using currently has a problem when compiled with GCC 11. GCC gives off this warning (for various complex reasons). GoogleTest has configured that any warnings the compiler gives should be treated as errors. And so GCC will stop compiling when it encounters that warning.

It's not your mistake, but up to GoogleTest to fix. A fix has been made and merged here: https://github.com/google/googletest/pull/3024

Updating GoogleTest to use version 1.11.0 or newer should resolve the problem.

Upvotes: 10

Related Questions