From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2181) id 4F0543858C52; Fri, 28 Oct 2022 23:56:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4F0543858C52 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1667001362; bh=MpH1lhjTSpBlchy/Gz0AqW+HTBjKezCdQxpXQ8Z/7i4=; h=From:To:Subject:Date:From; b=Qadfm1+NfoXHd/oFBqGGERav2kZv04Sw3frQ103p9Als5M+lCMWKbw4SDc2I0GtKa 2pD+YOtPQe1AP6nG8Zdja6rrliZlrvbGyAeRVtsC6lCmJqG0WiWzqszSewVRt6y4vD vgPIaZmwNMzxf3SE2Dfb4c4iqQB1TaNL5Afog5e0= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Jonathan Wakely To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc r13-3554] libstdc++: Fix dangling reference in filesystem::path::filename() X-Act-Checkin: gcc X-Git-Author: Jonathan Wakely X-Git-Refname: refs/heads/master X-Git-Oldrev: b80f25a3360b6850662eaea2039b255fbfbeea31 X-Git-Newrev: 49237fe6ef677a81eae701f937546210c90b5914 Message-Id: <20221028235602.4F0543858C52@sourceware.org> Date: Fri, 28 Oct 2022 23:56:01 +0000 (GMT) List-Id: https://gcc.gnu.org/g:49237fe6ef677a81eae701f937546210c90b5914 commit r13-3554-g49237fe6ef677a81eae701f937546210c90b5914 Author: Jonathan Wakely 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. 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 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 {}; }