public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/67302] New: copy elision in return (expression)
@ 2015-08-21 7:06 osensei80 at gmail dot com
2015-08-21 10:31 ` [Bug c++/67302] " redi at gcc dot gnu.org
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: osensei80 at gmail dot com @ 2015-08-21 7:06 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67302
Bug ID: 67302
Summary: copy elision in return (expression)
Product: gcc
Version: 5.1.0
Status: UNCONFIRMED
Severity: minor
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: osensei80 at gmail dot com
Target Milestone: ---
Consider:
struct A
{
A() { std::cout << "default ctor\n"; }
A(const A&) { std::cout << "copy ctor\n"; }
A(A&&) { std::cout << "move ctor\n"; }
};
A bar()
{
A a;
return( a );
}
int main()
{
bar();
}
Compiling with option -std=c++11 the output is "default ctor". But compiling
with -std=c++14 or -std=c++1z the output is
default ctor
move ctor
Why get's the move not elided?
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/67302] copy elision in return (expression)
2015-08-21 7:06 [Bug c++/67302] New: copy elision in return (expression) osensei80 at gmail dot com
@ 2015-08-21 10:31 ` redi at gcc dot gnu.org
2015-08-21 10:43 ` [Bug c++/67302] [C++14] " redi at gcc dot gnu.org
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: redi at gcc dot gnu.org @ 2015-08-21 10:31 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67302
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |wrong-code
Status|UNCONFIRMED |NEW
Last reconfirmed| |2015-08-21
Ever confirmed|0 |1
--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
The useless parentheses on the return expression disable elision, but that's a
bug.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/67302] [C++14] copy elision in return (expression)
2015-08-21 7:06 [Bug c++/67302] New: copy elision in return (expression) osensei80 at gmail dot com
2015-08-21 10:31 ` [Bug c++/67302] " redi at gcc dot gnu.org
@ 2015-08-21 10:43 ` redi at gcc dot gnu.org
2020-06-30 14:13 ` antoshkka at gmail dot com
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: redi at gcc dot gnu.org @ 2015-08-21 10:43 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67302
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jason at gcc dot gnu.org
Summary|copy elision in return |[C++14] copy elision in
|(expression) |return (expression)
--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Possibly started with the introduction of force_paren_expr in r197248
The fix for Bug 63437 allows it to compile, but didn't re-enable elision.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/67302] [C++14] copy elision in return (expression)
2015-08-21 7:06 [Bug c++/67302] New: copy elision in return (expression) osensei80 at gmail dot com
2015-08-21 10:31 ` [Bug c++/67302] " redi at gcc dot gnu.org
2015-08-21 10:43 ` [Bug c++/67302] [C++14] " redi at gcc dot gnu.org
@ 2020-06-30 14:13 ` antoshkka at gmail dot com
2021-06-19 19:39 ` ppalka at gcc dot gnu.org
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: antoshkka at gmail dot com @ 2020-06-30 14:13 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67302
Antony Polukhin <antoshkka at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |antoshkka at gmail dot com
--- Comment #3 from Antony Polukhin <antoshkka at gmail dot com> ---
Can reproduce with GCC 10.1 https://godbolt.org/z/tYvccG
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/67302] [C++14] copy elision in return (expression)
2015-08-21 7:06 [Bug c++/67302] New: copy elision in return (expression) osensei80 at gmail dot com
` (2 preceding siblings ...)
2020-06-30 14:13 ` antoshkka at gmail dot com
@ 2021-06-19 19:39 ` ppalka at gcc dot gnu.org
2021-06-21 11:56 ` cvs-commit at gcc dot gnu.org
2021-06-21 12:00 ` ppalka at gcc dot gnu.org
5 siblings, 0 replies; 7+ messages in thread
From: ppalka at gcc dot gnu.org @ 2021-06-19 19:39 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67302
Patrick Palka <ppalka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |ppalka at gcc dot gnu.org
Assignee|unassigned at gcc dot gnu.org |ppalka at gcc dot gnu.org
Status|NEW |ASSIGNED
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/67302] [C++14] copy elision in return (expression)
2015-08-21 7:06 [Bug c++/67302] New: copy elision in return (expression) osensei80 at gmail dot com
` (3 preceding siblings ...)
2021-06-19 19:39 ` ppalka at gcc dot gnu.org
@ 2021-06-21 11:56 ` cvs-commit at gcc dot gnu.org
2021-06-21 12:00 ` ppalka at gcc dot gnu.org
5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-06-21 11:56 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67302
--- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Patrick Palka <ppalka@gcc.gnu.org>:
https://gcc.gnu.org/g:21761d2b2b01f6cef4287c646845f6b3006546aa
commit r12-1698-g21761d2b2b01f6cef4287c646845f6b3006546aa
Author: Patrick Palka <ppalka@redhat.com>
Date: Mon Jun 21 07:54:29 2021 -0400
c++: REF_PARENTHESIZED_P wrapper inhibiting NRVO [PR67302]
Here, in C++14 or later, we remember the parentheses around 'a' in the
return statement by using a REF_PARENTHESIZED_P wrapper, which ends up
inhibiting NRVO because we don't look through this wrapper before
checking the conditions for NRVO. This patch fixes this by calling
maybe_undo_parenthesized_ref sooner in check_return_expr.
PR c++/67302
gcc/cp/ChangeLog:
* typeck.c (check_return_expr): Call maybe_undo_parenthesized_ref
sooner, before the NRVO handling.
gcc/testsuite/ChangeLog:
* g++.dg/opt/nrv21.C: New test.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/67302] [C++14] copy elision in return (expression)
2015-08-21 7:06 [Bug c++/67302] New: copy elision in return (expression) osensei80 at gmail dot com
` (4 preceding siblings ...)
2021-06-21 11:56 ` cvs-commit at gcc dot gnu.org
@ 2021-06-21 12:00 ` ppalka at gcc dot gnu.org
5 siblings, 0 replies; 7+ messages in thread
From: ppalka at gcc dot gnu.org @ 2021-06-21 12:00 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67302
Patrick Palka <ppalka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |FIXED
Target Milestone|--- |12.0
Status|ASSIGNED |RESOLVED
--- Comment #5 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Fixed for GCC 12, thanks for the bug report.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2021-06-21 12:00 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-08-21 7:06 [Bug c++/67302] New: copy elision in return (expression) osensei80 at gmail dot com
2015-08-21 10:31 ` [Bug c++/67302] " redi at gcc dot gnu.org
2015-08-21 10:43 ` [Bug c++/67302] [C++14] " redi at gcc dot gnu.org
2020-06-30 14:13 ` antoshkka at gmail dot com
2021-06-19 19:39 ` ppalka at gcc dot gnu.org
2021-06-21 11:56 ` cvs-commit at gcc dot gnu.org
2021-06-21 12:00 ` ppalka 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).