Skip to content

error: ‘dummy’ may be used uninitialized #1346

Description

@y2k0999
[ 55%] Building CXX object test/prefix/googletest/CMakeFiles/gtest.dir/src/gtest-all.cc.o
In file included from /home/gh/throw/yaml_test/yaml-cpp-yaml-cpp-0.7.0/test/gtest-1.10.0/googletest/src/gtest-all.cc:42:
/home/gh/throw/yaml_test/yaml-cpp-yaml-cpp-0.7.0/test/gtest-1.10.0/googletest/src/gtest-death-test.cc: In function ‘bool testing::internal::StackGrowsDown()’:
/home/gh/throw/yaml_test/yaml-cpp-yaml-cpp-0.7.0/test/gtest-1.10.0/googletest/src/gtest-death-test.cc:1301:24: error: ‘dummy’ may be used uninitialized [-Werror=maybe-uninitialized]
 1301 |   StackLowerThanAddress(&dummy, &result);
      |   ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
/home/gh/throw/yaml_test/yaml-cpp-yaml-cpp-0.7.0/test/gtest-1.10.0/googletest/src/gtest-death-test.cc:1290:13: note: by argument 1 of type ‘const void*’ to ‘void testing::internal::StackLowerThanAddress(const void*, bool*)’ declared here
 1290 | static void StackLowerThanAddress(const void* ptr, bool* result) {
      |             ^~~~~~~~~~~~~~~~~~~~~
/home/gh/throw/yaml_test/yaml-cpp-yaml-cpp-0.7.0/test/gtest-1.10.0/googletest/src/gtest-death-test.cc:1299:7: note: ‘dummy’ declared here
 1299 |   int dummy;
      |       ^~~~~
cc1plus: all warnings being treated as errors
make[2]: *** [test/prefix/googletest/CMakeFiles/gtest.dir/build.make:76: test/prefix/googletest/CMakeFiles/gtest.dir/src/gtest-all.cc.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:1038: test/prefix/googletest/CMakeFiles/gtest.dir/all] Error 2
make: *** [Makefile:146: all] Error 2

I had to go into yaml_test/yaml-cpp-yaml-cpp-0.7.0/test/gtest-1.10.0/googletest/src/gtest-death-test.cc and change line 1299
int dummy;
into
int dummy = 0;
then this issue went away. I suppose I could ignore warnings as well but whatever.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions