Recent versions of GCC warn about a possible dangling reference to a temporary:
/home/cvonelm/lo2s/src/perf/event_provider.cpp: In static member function ‘static const lo2s::perf::EventDescription& lo2s::perf::EventProvider::fallback_metric_leader_event()’:
/home/cvonelm/lo2s/src/perf/event_provider.cpp:308:37: warning: possibly dangling reference to a temporary [-Wdangling-reference]
308 | const EventDescription& ev = get_event_by_name(candidate);
| ^~
/home/cvonelm/lo2s/src/perf/event_provider.cpp:308:59: note: the temporary was destroyed at the end of the full expression ‘lo2s::perf::EventProvider::get_event_by_name(std::__cxx11::basic_string<char>(candidate, std::allocator<char>()))’
308 | const EventDescription& ev = get_event_by_name(candidate);
| ~~~~~~~~~~~~~~~~~^~~~~~~~~~~
Recent versions of GCC warn about a possible dangling reference to a temporary: