public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r11-10658] libstdc++: Fix dangling reference in filesystem::path::filename()
@ 2023-04-27 22:01 Jonathan Wakely
0 siblings, 0 replies; only message in thread
From: Jonathan Wakely @ 2023-04-27 22:01 UTC (permalink / raw)
To: gcc-cvs, libstdc++-cvs
https://gcc.gnu.org/g:7ced3e5179ee4fa3efaed5201e2c27c9168fdda0
commit r11-10658-g7ced3e5179ee4fa3efaed5201e2c27c9168fdda0
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Fri Oct 28 15:28:09 2022 +0100
libstdc++: Fix dangling reference in filesystem::path::filename()
The new -Wdangling-reference warning noticed this.
libstdc++-v3/ChangeLog:
* include/bits/fs_path.h (path::filename()): Fix dangling
reference.
(cherry picked from commit 49237fe6ef677a81eae701f937546210c90b5914)
Diff:
---
libstdc++-v3/include/bits/fs_path.h | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/libstdc++-v3/include/bits/fs_path.h b/libstdc++-v3/include/bits/fs_path.h
index f37e7e8909f..1188e585b14 100644
--- a/libstdc++-v3/include/bits/fs_path.h
+++ b/libstdc++-v3/include/bits/fs_path.h
@@ -1205,9 +1205,9 @@ namespace __detail
{
if (_M_pathname.back() == preferred_separator)
return {};
- auto& __last = *--end();
- if (__last._M_type() == _Type::_Filename)
- return __last;
+ auto __last = --end();
+ if (__last->_M_type() == _Type::_Filename)
+ return *__last;
}
return {};
}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-04-27 22:01 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-27 22:01 [gcc r11-10658] libstdc++: Fix dangling reference in filesystem::path::filename() Jonathan Wakely
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).