Skip to content

Conversation

maflcko
Copy link
Member

@maflcko maflcko commented Sep 29, 2021

This changes background_cs from being a pointer to a reference to work
around a gcc false warning. Also, this makes the test easier to read.

Fixes #23101

Can be reviewed with --ignore-all-space.

This changes background_cs from being a pointer to a reference to work
around a gcc false warning. Also, this makes the test easier to read.

Fixes bitcoin#23101

Can be reviewed with --ignore-all-space.
@maflcko
Copy link
Member Author

maflcko commented Sep 29, 2021

This is fixed in gcc8.4, I believe, but debian:buster still ships 8.3, in case anyone wants to test this: https://packages.debian.org/buster/gcc

@DrahtBot DrahtBot added the Tests label Sep 29, 2021
@katesalazar
Copy link
Contributor

thank you!

@practicalswift
Copy link
Contributor

Concept ACK

@mzumsande
Copy link
Contributor

A description with a link to the issue it fixes would be nice.

@maflcko
Copy link
Member Author

maflcko commented Sep 29, 2021

The description is in the body of the commit message.

@jnewbery
Copy link
Contributor

A description with a link to the issue it fixes would be nice.

The description is in the body of the commit message.

I agree that the description/link to issue should appear in the PR description, to make it easier for other contributors to quickly understand what the PR is doing.

@maflcko
Copy link
Member Author

maflcko commented Sep 29, 2021

Ok, copy-pasted the description

@practicalswift
Copy link
Contributor

cr ACK fa4d0aa

@laanwj laanwj changed the title test: * -> & test: * -> & to work around false warning in gcc 8.3 Sep 30, 2021
@laanwj
Copy link
Member

laanwj commented Sep 30, 2021

Concept ACK

I've tried to make the PR title clearer, but I don't know: does this only affect gcc 8.3 or a wider version range?

@maflcko maflcko changed the title test: * -> & to work around false warning in gcc 8.3 test: Change background_cs from pointer to reference in validation_chainstate_tests Sep 30, 2021
@maflcko
Copy link
Member Author

maflcko commented Sep 30, 2021

No idea which gcc version are affected. I only tested debian-gcc-8.3

@katesalazar
Copy link
Contributor

Nobody needs to sweat it, who cares, simply keep GCC 8.3 for now.

Ideally, you would find out the answer by reading CI workers' logs,
not by asking peers.

@maflcko
Copy link
Member Author

maflcko commented Oct 1, 2021

We don't have the resources to maintain CI scripts for every operating system and every compiler version, so I think asking which version is affected seems reasonable.

@katesalazar
Copy link
Contributor

Concept ACK

I've tried to make the PR title clearer, but I don't know: does this only affect gcc 8.3 or a wider version range?

@laanwj note GCC 9 at #23149 (comment).

@hebasto
Copy link
Member

hebasto commented Oct 11, 2021

Concept ACK.

@jamesob
Copy link
Contributor

jamesob commented Oct 11, 2021

ACK fa4d0aa

Reviewed code on Github.

Copy link
Member

@hebasto hebasto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK fa4d0aa, tested on Linux Mint 20.2 (x86_64) by merging this PR on top of the current master.

Compiler:

$ gcc --version
gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ make > /dev/null 
test/fuzz/float.cpp: In function ‘void float_fuzz_target(FuzzBufferType)’:
test/fuzz/float.cpp:60:30: warning: ‘tmp’ may be used uninitialized in this function [-Wmaybe-uninitialized]
   60 |         assert(std::isnan(d) || d == d_deserialized);
      |                              ^~
In file included from ./validation.h:15,
                 from ./test/util/chainstate.h:13,
                 from test/validation_chainstate_tests.cpp:11:
./chain.h: In member function ‘void validation_chainstate_tests::chainstate_update_tip::test_method()’:
./chain.h:422:27: warning: ‘background_cs’ may be used uninitialized in this function [-Wmaybe-uninitialized]
  422 |         return vChain.size() > 0 ? vChain[vChain.size() - 1] : nullptr;
      |                ~~~~~~~~~~~^~
test/validation_chainstate_tests.cpp:110:18: note: ‘background_cs’ was declared here
  110 |     CChainState* background_cs;
      |                  ^~~~~~~~~~~~~
$ make > /dev/null 
test/fuzz/float.cpp: In function ‘void float_fuzz_target(FuzzBufferType)’:
test/fuzz/float.cpp:60:30: warning: ‘tmp’ may be used uninitialized in this function [-Wmaybe-uninitialized]
   60 |         assert(std::isnan(d) || d == d_deserialized);
      |                              ^~

}
}
BOOST_CHECK(background_cs);
assert(false);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Include <cassert> header?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nicer to be able to run iwyu on the codebase rather than spend time on reviewing includes. Also, assert is already used in this file, so this seems unrelated.

@maflcko maflcko merged commit 8df7eee into bitcoin:master Oct 12, 2021
@maflcko maflcko deleted the 2109-testStarToAmpersand branch October 12, 2021 06:54
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Oct 12, 2021
@bitcoin bitcoin locked and limited conversation to collaborators Oct 30, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

compiler warning on building src/test/test_bitcoin-validation_chainstate_tests.o
9 participants