From afe17f10c143ccc41ba94fe64d1b7d015e2da517 Mon Sep 17 00:00:00 2001 From: Johannes Schmidt Date: Thu, 12 Feb 2026 15:00:29 +0100 Subject: [PATCH] Silence -Wdangling-reference warning in ApplyRule This is a false-positive because the functions in question return a reference to memory in a static variable that remains fixed after program start. This commit adds a macro for the `[[gnu::no_dangling]]` attribute to ignore the warning for the tagged functions and uses that macro on both functions returning references to the static variable. --- lib/config/applyrule.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/config/applyrule.hpp b/lib/config/applyrule.hpp index 0acc1c994..532529872 100644 --- a/lib/config/applyrule.hpp +++ b/lib/config/applyrule.hpp @@ -81,8 +81,8 @@ public: const Expression::Ptr& filter, const String& package, const String& fkvar, const String& fvvar, const Expression::Ptr& fterm, bool ignoreOnError, const DebugInfo& di, const Dictionary::Ptr& scope); static const std::vector& GetRules(const Type::Ptr& sourceType, const Type::Ptr& targetType); - static const std::set& GetTargetedHostRules(const Type::Ptr& sourceType, const String& host); - static const std::set& GetTargetedServiceRules(const Type::Ptr& sourceType, const String& host, const String& service); + [[gnu::no_dangling]] static const std::set& GetTargetedHostRules(const Type::Ptr& sourceType, const String& host); + [[gnu::no_dangling]] static const std::set& GetTargetedServiceRules(const Type::Ptr& sourceType, const String& host, const String& service); static bool GetTargetHosts(Expression* assignFilter, std::vector& hosts, const Dictionary::Ptr& constants = nullptr); static bool GetTargetServices(Expression* assignFilter, std::vector>& services, const Dictionary::Ptr& constants = nullptr);