yaml-cpp icon indicating copy to clipboard operation
yaml-cpp copied to clipboard

error: ‘dummy’ may be used uninitialized

Open y2k0999 opened this issue 10 months ago • 1 comments

[ 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.

y2k0999 avatar Mar 03 '25 03:03 y2k0999

I had the same issue.. since it is a gtest code, I avoided this compiling with -DYAML_CPP_BUILD_TESTS=OFF but still it is a workaround.

joanvallve avatar Sep 29 '25 11:09 joanvallve