Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compile error in 1.10.0 while using GCC 11 #3219

Closed
PragmaTwice opened this issue Jan 13, 2021 · 3 comments
Closed

Compile error in 1.10.0 while using GCC 11 #3219

PragmaTwice opened this issue Jan 13, 2021 · 3 comments

Comments

@PragmaTwice
Copy link

PragmaTwice commented Jan 13, 2021

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

@JackBoosY
Copy link

I think this should be a gtest bug and should be fixed here instead of vcpkg.

@ghost
Copy link

ghost commented Jan 14, 2021

It looks like #3024 fix this issue

elsid added a commit to elsid/ozo that referenced this issue Jun 9, 2021
Described here: google/googletest#3219

/home/elsid/dev/ozo/build/pg/gcc_debug/tests/GoogleTest-prefix/src/GoogleTest/googletest/src/gtest-death-test.cc: In function ‘bool testing::internal::StackGrowsDown()’:
/home/elsid/dev/ozo/build/pg/gcc_debug/tests/GoogleTest-prefix/src/GoogleTest/googletest/src/gtest-death-test.cc:1301:24: error: ‘dummy’ may be used uninitialized [-Werror=maybe-uninitialized]
 1301 |   StackLowerThanAddress(&dummy, &result);
      |   ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
/home/elsid/dev/ozo/build/pg/gcc_debug/tests/GoogleTest-prefix/src/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/elsid/dev/ozo/build/pg/gcc_debug/tests/GoogleTest-prefix/src/GoogleTest/googletest/src/gtest-death-test.cc:1299:7: note: ‘dummy’ declared here
 1299 |   int dummy;
      |       ^~~~~
This was referenced Sep 4, 2021
MarcelKoch added a commit to ginkgo-project/ginkgo that referenced this issue Oct 26, 2021
The current GTest version is incompatible with gcc 11.2, which has already been mentioned somewhere, see also [2](google/googletest#3219).
Since GTest now also follows abseil's live at head philosophy (see [2](https://abseil.io/about/philosophy#upgrade-support)), they advise using the latest commit in master. 
If we decide against that, we should update to the latest release v1.11.0 with `e2239ee6043f73722e7aa812a459f54a28552929`.
PiRK added a commit to PiRK/wallet-core that referenced this issue Jan 12, 2022
Recent versions of gcc changed some rule about uninitialized variables, causing a warning which is for some reason considered as an error when I try to run `bootstrap.sh`. See google/googletest#3219 and google/googletest#3024

This fixes it by applying a patch  which is already in the master branch of googletest, but not in the release version used by the script.
vmironovich added a commit to vmironovich/IOHexperimenter that referenced this issue Jan 30, 2022
Fixes compilation error with GCC 11, see google/googletest#3219
erikogenvik added a commit to erikogenvik/ogre that referenced this issue Apr 12, 2022
paroj pushed a commit to OGRECave/ogre that referenced this issue Apr 12, 2022
ja2-derek added a commit to ja2-derek/ja2-stracciatella that referenced this issue Oct 15, 2022
So it can be built with gcc-11. See also: google/googletest#3219
algoriddle added a commit to algoriddle/faiss that referenced this issue Oct 19, 2022
Summary:
Due to google/googletest#3219 gtest doesn't compile with gcc 11 - Ubuntu 22.04 has GCC 11.2 currently.

The fix was google/googletest#3024 so I'm bumping gtest to latest.

Differential Revision: D40512746

fbshipit-source-id: b938eec96f0cb6e13e20daab529f97527c8e31c0
facebook-github-bot pushed a commit to facebookresearch/faiss that referenced this issue Oct 20, 2022
Summary:
Pull Request resolved: #2538

Due to google/googletest#3219 gtest doesn't compile with gcc 11 - Ubuntu 22.04 has GCC 11.2 currently.

The fix was google/googletest#3024 so I'm bumping gtest to latest.

Reviewed By: alexanderguzhva

Differential Revision: D40512746

fbshipit-source-id: 75f3c3c7f8a117af8430c2f74a7f8d164ca9877b
cyrilRomain pushed a commit to cyrilRomain/seeded-crypto that referenced this issue Dec 5, 2022
@starball5
Copy link

This bug recently appeared in a Stack Overflow question: Why do I get an error about a dummy variable when building googletest v1.10 with GCC 11?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants