google / googletest

GoogleTest - Google Testing and Mocking Framework

Home Page:https://google.github.io/googletest/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Compilation error when using g++ 11.2.0 with release-1.10.0

jparisu opened this issue · comments

Describe the bug

This CMake project fails in compilation when g++ 11.2.0 is used (default g++ in Ubuntu 22.04) with version release-1.10.0
It fails for a uninitialized variable.

Steps to reproduce the bug

  • Use Ubuntu 22.04 (ubuntu:latest in Dockerhub)
  • download repository googletest (by clone)
  • switch to tag: release-1.10.0
  • compile project

The following error arises:

In file included from /home/wks/src/googletest-distribution/googletest/src/gtest-all.cc:42:
/home/wks/src/googletest-distribution/googletest/src/gtest-death-test.cc: In function ‘bool testing::internal::StackGrowsDown()’:
/home/wks/src/googletest-distribution/googletest/src/gtest-death-test.cc:1301:24: error: ‘dummy’ may be used uninitialized [-Werror=maybe-uninitialized]
 1301 |   StackLowerThanAddress(&dummy, &result);
      |   ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
/home/wks/src/googletest-distribution/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/wks/src/googletest-distribution/googletest/src/gtest-death-test.cc:1299:7: note: ‘dummy’ declared here
 1299 |   int dummy;
      |       ^~~~~
cc1plus: all warnings being treated as errors
gmake[2]: *** [googletest/CMakeFiles/gtest.dir/build.make:76: googletest/CMakeFiles/gtest.dir/src/gtest-all.cc.o] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:172: googletest/CMakeFiles/gtest.dir/all] Error 2
gmake: *** [Makefile:146: all] Error 2

Does the bug persist in the most recent commit?

It does not. But we use version release-1.10.0 due to some errors that we encountered when updating to new versions.

What operating system and version are you using?

Ubuntu 22.04 LTS

What compiler and version are you using?

g++ (Ubuntu 11.2.0-19ubuntu1) 11.2.0

What build system are you using?

cmake version 3.22.1
We are using colcon, ROS 2 superbuild tool.
https://colcon.readthedocs.io/en/released/

Additional context

The fix is very simple, and if your team give me positive feedback I could prepare a PR to fix it.

We do not plan to patch 1.10 other than for exceptional circumstances, such as security issues. Please try using a newer version of GoogleTest.
And if that is not an option, please let us know why.

Resolved by 4679637