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
This commit is contained in:
MarcoFalke 2025-11-05 08:43:11 +01:00
parent fa5fbcd615
commit fae1d99651
No known key found for this signature in database
3 changed files with 13 additions and 4 deletions

View File

@ -19,4 +19,10 @@ export GOAL="install"
export CI_LIMIT_STACK_SIZE=1
# -Wno-psabi is to disable ABI warnings: "note: parameter passing for argument of type ... changed in GCC 7.1"
# This could be removed once the ABI change warning does not show up by default
export BITCOIN_CONFIG="-DREDUCE_EXPORTS=ON -DCMAKE_CXX_FLAGS='-Wno-psabi -Wno-error=maybe-uninitialized'"
#
# -Wno-error=dangling-reference helps to work around a GCC 13.1 false-positive,
# fixed in later versions.
export BITCOIN_CONFIG=" \
-DREDUCE_EXPORTS=ON \
-DCMAKE_CXX_FLAGS='-Wno-psabi -Wno-error=dangling-reference -Wno-error=maybe-uninitialized' \
"

View File

@ -13,5 +13,8 @@ export PACKAGES="g++-mingw-w64-x86-64-posix nsis"
export RUN_UNIT_TESTS=false
export RUN_FUNCTIONAL_TESTS=false
export GOAL="deploy"
# -Wno-error=dangling-reference helps to work around a GCC 13.1 false-positive,
# fixed in later versions.
export BITCOIN_CONFIG="-DREDUCE_EXPORTS=ON -DBUILD_GUI_TESTS=OFF -DBUILD_KERNEL_LIB=ON -DBUILD_KERNEL_TEST=ON \
-DCMAKE_CXX_FLAGS='-Wno-error=maybe-uninitialized'"
-DCMAKE_CXX_FLAGS='-Wno-error=dangling-reference -Wno-error=maybe-uninitialized' \
"

View File

@ -66,7 +66,7 @@ void assertion_fail(const std::source_location& loc, std::string_view assertion)
/** Helper for CHECK_NONFATAL() */
template <typename T>
T&& inline_check_non_fatal(LIFETIMEBOUND T&& val, std::source_location loc, std::string_view assertion)
T&& inline_check_non_fatal(LIFETIMEBOUND T&& val, const std::source_location& loc, std::string_view assertion)
{
if (!val) {
if constexpr (G_ABORT_ON_FAILED_ASSUME) {
@ -83,7 +83,7 @@ T&& inline_check_non_fatal(LIFETIMEBOUND T&& val, std::source_location loc, std:
/** Helper for Assert()/Assume() */
template <bool IS_ASSERT, typename T>
constexpr T&& inline_assertion_check(LIFETIMEBOUND T&& val, [[maybe_unused]] std::source_location loc, [[maybe_unused]] std::string_view assertion)
constexpr T&& inline_assertion_check(LIFETIMEBOUND T&& val, [[maybe_unused]] const std::source_location& loc, [[maybe_unused]] std::string_view assertion)
{
if (IS_ASSERT || std::is_constant_evaluated() || G_ABORT_ON_FAILED_ASSUME) {
if (!val) {