aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Wakely <jwakely@redhat.com>2022-10-28 15:28:09 +0100
committerJonathan Wakely <jwakely@redhat.com>2022-10-29 00:55:42 +0100
commit49237fe6ef677a81eae701f937546210c90b5914 (patch)
treeec93c16f1fa778d95b1b2c30a17aebf2855f5ea7
parentb80f25a3360b6850662eaea2039b255fbfbeea31 (diff)
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.
-rw-r--r--libstdc++-v3/include/bits/fs_path.h6
1 files changed, 3 insertions, 3 deletions
diff --git a/libstdc++-v3/include/bits/fs_path.h b/libstdc++-v3/include/bits/fs_path.h
index 6e7b366d104..2fc7dcd98c9 100644
--- a/libstdc++-v3/include/bits/fs_path.h
+++ b/libstdc++-v3/include/bits/fs_path.h
@@ -1262,9 +1262,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 {};
}