Skip to content

Commit fae1d99

Browse files
author
MarcoFalke
committed
refactor: Use const reference to std::source_location
Performance likely does not matter here, but from a perspective of code-readablilty, a const reference should be preferred for read-only access. So use it here. This requires to set -Wno-error=dangling-reference for GCC 13.1 compilations, but this false-positive is fixed in later GCC versions. See also https://godbolt.org/z/fjc6be65M
1 parent fa5fbcd commit fae1d99

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

ci/test/00_setup_env_arm.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,10 @@ export GOAL="install"
1919
export CI_LIMIT_STACK_SIZE=1
2020
# -Wno-psabi is to disable ABI warnings: "note: parameter passing for argument of type ... changed in GCC 7.1"
2121
# This could be removed once the ABI change warning does not show up by default
22-
export BITCOIN_CONFIG="-DREDUCE_EXPORTS=ON -DCMAKE_CXX_FLAGS='-Wno-psabi -Wno-error=maybe-uninitialized'"
22+
#
23+
# -Wno-error=dangling-reference helps to work around a GCC 13.1 false-positive,
24+
# fixed in later versions.
25+
export BITCOIN_CONFIG=" \
26+
-DREDUCE_EXPORTS=ON \
27+
-DCMAKE_CXX_FLAGS='-Wno-psabi -Wno-error=dangling-reference -Wno-error=maybe-uninitialized' \
28+
"

ci/test/00_setup_env_win64.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,8 @@ export PACKAGES="g++-mingw-w64-x86-64-posix nsis"
1313
export RUN_UNIT_TESTS=false
1414
export RUN_FUNCTIONAL_TESTS=false
1515
export GOAL="deploy"
16+
# -Wno-error=dangling-reference helps to work around a GCC 13.1 false-positive,
17+
# fixed in later versions.
1618
export BITCOIN_CONFIG="-DREDUCE_EXPORTS=ON -DBUILD_GUI_TESTS=OFF -DBUILD_KERNEL_LIB=ON -DBUILD_KERNEL_TEST=ON \
17-
-DCMAKE_CXX_FLAGS='-Wno-error=maybe-uninitialized'"
19+
-DCMAKE_CXX_FLAGS='-Wno-error=dangling-reference -Wno-error=maybe-uninitialized' \
20+
"

src/util/check.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ void assertion_fail(const std::source_location& loc, std::string_view assertion)
6666

6767
/** Helper for CHECK_NONFATAL() */
6868
template <typename T>
69-
T&& inline_check_non_fatal(LIFETIMEBOUND T&& val, std::source_location loc, std::string_view assertion)
69+
T&& inline_check_non_fatal(LIFETIMEBOUND T&& val, const std::source_location& loc, std::string_view assertion)
7070
{
7171
if (!val) {
7272
if constexpr (G_ABORT_ON_FAILED_ASSUME) {
@@ -83,7 +83,7 @@ T&& inline_check_non_fatal(LIFETIMEBOUND T&& val, std::source_location loc, std:
8383

8484
/** Helper for Assert()/Assume() */
8585
template <bool IS_ASSERT, typename T>
86-
constexpr T&& inline_assertion_check(LIFETIMEBOUND T&& val, [[maybe_unused]] std::source_location loc, [[maybe_unused]] std::string_view assertion)
86+
constexpr T&& inline_assertion_check(LIFETIMEBOUND T&& val, [[maybe_unused]] const std::source_location& loc, [[maybe_unused]] std::string_view assertion)
8787
{
8888
if (IS_ASSERT || std::is_constant_evaluated() || G_ABORT_ON_FAILED_ASSUME) {
8989
if (!val) {

0 commit comments

Comments
 (0)