tud-zih-energy / lo2s

Linux OTF2 Sampling - A Lightweight Node-Level Performance Monitoring Tool
https://tu-dresden.de/zih/forschung/projekte/lo2s?set_language=en
GNU General Public License v3.0
45 stars 13 forks source link

Fix dangling reference to temporary warning. #281

Closed cvonelm closed 1 year ago

cvonelm commented 1 year ago

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);
      |                                          ~~~~~~~~~~~~~~~~~^~~~~~~~~~~