refactor: Use const reference to std::source_location
What changed, and why it matters
This is a minor code cleanup (refactor) that changes how a diagnostic helper passes a C++ standard library object. It does not fix a security bug, change behavior, or introduce a vulnerability. The accompanying build-script changes only suppress a compiler warning that newer compilers would not emit anyway.
No security action needed. Treat as ordinary refactoring/build-maintenance commit.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit changes two inline helper templates in src/util/check.h to take std::source_location by const reference instead of by value. std::source_location is a small, cheap-to-copy type, so this is purely stylistic/readability. The CI environment scripts add -Wno-error=dangling-reference for GCC 13.1 because that compiler version falsely flags the const-reference parameter as a potential dangling reference; later GCC versions fix the false positive. No functional or security-relevant change is present in the diff.
Changed components
src/util/check.hci/test/00_setup_env_arm.shci/test/00_setup_env_win64.shInspect captured patch +13 / −4
diff --git a/ci/test/00_setup_env_arm.sh b/ci/test/00_setup_env_arm.sh
index ce019784..d5b2bb4b 100755
--- a/ci/test/00_setup_env_arm.sh
+++ b/ci/test/00_setup_env_arm.sh
@@ -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' \
+"
diff --git a/ci/test/00_setup_env_win64.sh b/ci/test/00_setup_env_win64.sh
index 1ea67230..06134457 100755
--- a/ci/test/00_setup_env_win64.sh
+++ b/ci/test/00_setup_env_win64.sh
@@ -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' \
+"
diff --git a/src/util/check.h b/src/util/check.h
index fc9fa127..0d08a473 100644
--- a/src/util/check.h
+++ b/src/util/check.h
@@ -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) {
Why this scored 14/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.