public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/113256] New: False -Wdangling-reference positive
@ 2024-01-07 2:20 pdimov at gmail dot com
2024-01-18 21:28 ` [Bug c++/113256] " mpolacek at gcc dot gnu.org
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: pdimov at gmail dot com @ 2024-01-07 2:20 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113256
Bug ID: 113256
Summary: False -Wdangling-reference positive
Product: gcc
Version: 13.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: pdimov at gmail dot com
Target Milestone: ---
The following code
```
#include <utility>
#include <cassert>
template<class M, class T, class A> auto bind( M T::* pm, A a )
{
return [=]( auto&& x ) -> M const& { return x.*pm; };
}
template<int I> struct arg {};
arg<1> _1;
int main()
{
std::pair<int, int> pair;
int const& x = bind( &std::pair<int, int>::first, _1 )( pair );
assert( &x == &pair.first );
}
```
(https://godbolt.org/z/a555MMTqo)
(reduced from a Boost.Bind test case)
causes
```
<source>:16:16: warning: possibly dangling reference to a temporary
[-Wdangling-reference]
16 | int const& x = bind( &std::pair<int, int>::first, _1 )( pair );
| ^
```
with GCC 13.2 (but not trunk).
There are indeed two temporaries created in that full expression, but `int
const&` can't possibly bind to any of them.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/113256] False -Wdangling-reference positive
2024-01-07 2:20 [Bug c++/113256] New: False -Wdangling-reference positive pdimov at gmail dot com
@ 2024-01-18 21:28 ` mpolacek at gcc dot gnu.org
2024-01-23 21:36 ` cvs-commit at gcc dot gnu.org
2024-01-23 22:32 ` mpolacek at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2024-01-18 21:28 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113256
Marek Polacek <mpolacek at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2024-01-18
Ever confirmed|0 |1
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/113256] False -Wdangling-reference positive
2024-01-07 2:20 [Bug c++/113256] New: False -Wdangling-reference positive pdimov at gmail dot com
2024-01-18 21:28 ` [Bug c++/113256] " mpolacek at gcc dot gnu.org
@ 2024-01-23 21:36 ` cvs-commit at gcc dot gnu.org
2024-01-23 22:32 ` mpolacek at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-01-23 21:36 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113256
--- Comment #1 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The trunk branch has been updated by Marek Polacek <mpolacek@gcc.gnu.org>:
https://gcc.gnu.org/g:9010fdba68063beccfbab0aa9ec8739f232ca2f4
commit r14-8375-g9010fdba68063beccfbab0aa9ec8739f232ca2f4
Author: Marek Polacek <polacek@redhat.com>
Date: Fri Jan 19 13:59:41 2024 -0500
c++: -Wdangling-reference and lambda false warning [PR109640]
-Wdangling-reference checks if a function receives a temporary as its
argument, and only warns if any of the arguments was a temporary. But
we should not warn when the temporary represents a lambda or we generate
false positives as in the attached testcases.
PR c++/113256
PR c++/111607
PR c++/109640
gcc/cp/ChangeLog:
* call.cc (do_warn_dangling_reference): Don't warn if the temporary
is of lambda type.
gcc/testsuite/ChangeLog:
* g++.dg/warn/Wdangling-reference14.C: New test.
* g++.dg/warn/Wdangling-reference15.C: New test.
* g++.dg/warn/Wdangling-reference16.C: New test.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/113256] False -Wdangling-reference positive
2024-01-07 2:20 [Bug c++/113256] New: False -Wdangling-reference positive pdimov at gmail dot com
2024-01-18 21:28 ` [Bug c++/113256] " mpolacek at gcc dot gnu.org
2024-01-23 21:36 ` cvs-commit at gcc dot gnu.org
@ 2024-01-23 22:32 ` mpolacek at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2024-01-23 22:32 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113256
Marek Polacek <mpolacek at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution|--- |FIXED
--- Comment #2 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Should be fixed; thanks for the report.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-01-23 22:32 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-07 2:20 [Bug c++/113256] New: False -Wdangling-reference positive pdimov at gmail dot com
2024-01-18 21:28 ` [Bug c++/113256] " mpolacek at gcc dot gnu.org
2024-01-23 21:36 ` cvs-commit at gcc dot gnu.org
2024-01-23 22:32 ` mpolacek at gcc dot gnu.org
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).