Skip to content

Commit 0f79db3

Browse files
pypingouclaude
andcommitted
Fix dangling reference in skeleton service element factory template
Resolved final GCC 15 dangling reference warning in the template-heavy skeleton service element binding factory where string_view parameters were being converted to temporary std::string objects: GetServiceElementInstanceDeployment(deployment, std::string{service_element_name}); GetServiceElementId(deployment, std::string{service_element_name}); The issue: std::string{service_view} creates a temporary string, and if the called functions return references to data within that temporary, the reference becomes dangling when the temporary is destroyed. Fixed by: - Creating explicit string variable from string_view - Reusing the same string for both function calls - Ensuring all references point to the stable string object This eliminates the last dangling reference in the codebase and ensures the skeleton binding system works correctly with all compiler versions and optimization levels. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 253048f commit 0f79db3

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

score/mw/com/impl/plumbing/skeleton_service_element_binding_factory_impl.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,13 +100,14 @@ auto CreateSkeletonServiceElement(const InstanceIdentifier& identifier,
100100
const auto& lola_service_instance_deployment =
101101
GetServiceInstanceDeploymentBinding<LolaServiceInstanceDeployment>(service_instance_deployment);
102102

103+
std::string service_element_name_str{service_element_name};
103104
const auto& lola_service_element_instance_deployment = GetServiceElementInstanceDeployment<element_type>(
104-
lola_service_instance_deployment, std::string{service_element_name});
105+
lola_service_instance_deployment, service_element_name_str);
105106
const auto skeleton_event_properties =
106107
detail::GetSkeletonEventProperties(lola_service_element_instance_deployment);
107108

108109
const auto lola_service_element_id =
109-
GetServiceElementId<element_type>(lola_service_type_deployment, std::string{service_element_name});
110+
GetServiceElementId<element_type>(lola_service_type_deployment, service_element_name_str);
110111
const lola::ElementFqId element_fq_id{lola_service_type_deployment.service_id_,
111112
lola_service_element_id,
112113
lola_service_instance_deployment.instance_id_.value().GetId(),

0 commit comments

Comments
 (0)