Currently build with -Wdangling-reference (g++ 14.1.0) gives the following:
.../date/include/date/date.h:6594:15: error: possibly dangling reference to a temporary [-Werror=dangling-reference]
6594 | auto& f = std::use_facet<std::time_get<CharT>>(is.getloc());
.../date/include/date/date.h:6594:55: note: the temporary was destroyed at the end of the full expression ‘std::use_facet<__cxx11::time_get<char> >(std::ios_base::getloc() const())’
See https://github.com/HowardHinnant/date/blob/master/include/date/date.h#L6594
The following patch fixes the issue for me:
#if !ONLY_C_LOCALE
- auto& f = std::use_facet<std::time_get<CharT>>(is.getloc());
+ auto loc = is.getloc();
+ auto& f = std::use_facet<std::time_get<CharT>>(loc);
std::tm tm{};
#endif
Currently build with
-Wdangling-reference(g++ 14.1.0) gives the following:See https://github.com/HowardHinnant/date/blob/master/include/date/date.h#L6594
The following patch fixes the issue for me: