Skip to content

Compile error in 1.10.0 while using GCC 11 #3219

@PragmaTwice

Description

@PragmaTwice

The build error is caused by a new warning (something may be used uninitialized) in GCC 11 and -Werror in CMake configuration of gtest.
Master branch has fixed this compile error, but sometimes we cannot use the master version, i.e. while we use some package/dependency managers like vcpkg.

  • OS: Linux 5.8.18-1-MANJARO
  • Compiler: g++ (GCC) 11.0.0 20201227 (experimental)
Scanning dependencies of target gtest
[ 12%] Building CXX object googletest/CMakeFiles/gtest.dir/src/gtest-all.cc.o
In file included from /home/twice/googletest/googletest/src/gtest-all.cc:42:
/home/twice/googletest/googletest/src/gtest-death-test.cc: In function ‘bool testing::internal::StackGrowsDown()’:
/home/twice/googletest/googletest/src/gtest-death-test.cc:1301:24: error: ‘dummy’ may be used uninitialized [-Werror=maybe-uninitialized]
 1301 |   StackLowerThanAddress(&dummy, &result);
      |   ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
/home/twice/googletest/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/twice/googletest/googletest/src/gtest-death-test.cc:1299:7: note: ‘dummy’ declared here
 1299 |   int dummy;
      |       ^~~~~
cc1plus: all warnings being treated as errors
make[2]: *** [googletest/CMakeFiles/gtest.dir/build.make:82:googletest/CMakeFiles/gtest.dir/src/gtest-all.cc.o] error 1
make[1]: *** [CMakeFiles/Makefile2:219:googletest/CMakeFiles/gtest.dir/all] error 2
make: *** [Makefile:160:all] error 2

I also created an issue in vcpkg (microsoft/vcpkg#15617).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions