public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/63437] New: [4.9/5 regression][C++14] Parenthesized "movable but not copyable" object doesn't compile in return statement
@ 2014-10-02 2:26 flast at flast dot jp
2014-10-02 3:03 ` [Bug c++/63437] " pinskia at gcc dot gnu.org
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: flast at flast dot jp @ 2014-10-02 2:26 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63437
Bug ID: 63437
Summary: [4.9/5 regression][C++14] Parenthesized "movable but
not copyable" object doesn't compile in return
statement
Product: gcc
Version: 4.9.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: flast at flast dot jp
After GCC 4.9, parenthesized "movable but not copyable" object doesn't compile
in return statement under C++14 mode (C++11 mode does compile).
I'm not sure that the behavior was changed in C++14 spec; Clang seems compile
under both of C++11/14 mode.
example:
----
struct X // movable but not copyable
{
X() = default;
X(X &&) = default;
X(const X &) = delete;
};
X non_parenthesized()
{
X x;
return x; // works
}
X parenthesized()
{
X x;
return (x); // error: use of deleted function 'X::X(const X&)'
}
----
Online compiler results:
- GCC 4.8.2
- C++11 http://melpon.org/wandbox/permlink/lRR60fvDgKfqd0UZ
- C++14 http://melpon.org/wandbox/permlink/BAdrBmEG3euQLnqv
- GCC 4.9.1
- C++11 http://melpon.org/wandbox/permlink/XllfUNu0VV0mnYsu
- C++14 http://melpon.org/wandbox/permlink/qm67F6vODyADgKvQ (fail)
- GCC 5.0 20141001
- C++11 http://melpon.org/wandbox/permlink/21bPbcuXB7S87DUG
- C++14 http://melpon.org/wandbox/permlink/da8AeqX7HrS17T2n (fail)
- Clang 3.5.0
- C++11 http://melpon.org/wandbox/permlink/VqgnlKRTOBHd5IDt
- C++14 http://melpon.org/wandbox/permlink/tAkgLiaD50nOMtEz
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/63437] [4.9/5 regression][C++14] Parenthesized "movable but not copyable" object doesn't compile in return statement
2014-10-02 2:26 [Bug c++/63437] New: [4.9/5 regression][C++14] Parenthesized "movable but not copyable" object doesn't compile in return statement flast at flast dot jp
@ 2014-10-02 3:03 ` pinskia at gcc dot gnu.org
2014-10-02 7:40 ` flast at flast dot jp
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu.org @ 2014-10-02 3:03 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63437
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
in C++14 (a) means the same as static_cast<typeof(a) &>(a).
So it is a reference at this point which means const & is better than &&.
Or at least that is how I understand this. Does clang implement the C++11 ()
rule correctly?
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/63437] [4.9/5 regression][C++14] Parenthesized "movable but not copyable" object doesn't compile in return statement
2014-10-02 2:26 [Bug c++/63437] New: [4.9/5 regression][C++14] Parenthesized "movable but not copyable" object doesn't compile in return statement flast at flast dot jp
2014-10-02 3:03 ` [Bug c++/63437] " pinskia at gcc dot gnu.org
@ 2014-10-02 7:40 ` flast at flast dot jp
2014-10-02 9:08 ` redi at gcc dot gnu.org
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: flast at flast dot jp @ 2014-10-02 7:40 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63437
--- Comment #2 from Kohei Takahashi <flast at flast dot jp> ---
(In reply to Andrew Pinski from comment #1)
> in C++14 (a) means the same as static_cast<typeof(a) &>(a).
>
> So it is a reference at this point which means const & is better than &&.
>
> Or at least that is how I understand this. Does clang implement the C++11
> () rule correctly?
n3376 12.8 [class.copy] paragraph 32 says:
When the criteria for elision of a copy operation are met or would be met
save for the fact that the source
object is a function parameter, and the object to be copied is designated
by an lvalue, overload resolution to
select the constructor for the copy is first performed as if the object
were designated by an rvalue.
And latest draft says more clearly.
https://github.com/cplusplus/draft/blob/master/source/special.tex#L3021-L3062
Therefore, I think move should be performed even if parenthesized.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/63437] [4.9/5 regression][C++14] Parenthesized "movable but not copyable" object doesn't compile in return statement
2014-10-02 2:26 [Bug c++/63437] New: [4.9/5 regression][C++14] Parenthesized "movable but not copyable" object doesn't compile in return statement flast at flast dot jp
2014-10-02 3:03 ` [Bug c++/63437] " pinskia at gcc dot gnu.org
2014-10-02 7:40 ` flast at flast dot jp
@ 2014-10-02 9:08 ` redi at gcc dot gnu.org
2014-10-09 18:05 ` jason at gcc dot gnu.org
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: redi at gcc dot gnu.org @ 2014-10-02 9:08 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63437
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2014-10-02
Ever confirmed|0 |1
--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Yes, the new wording is clear that parenthesized names are OK.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/63437] [4.9/5 regression][C++14] Parenthesized "movable but not copyable" object doesn't compile in return statement
2014-10-02 2:26 [Bug c++/63437] New: [4.9/5 regression][C++14] Parenthesized "movable but not copyable" object doesn't compile in return statement flast at flast dot jp
` (2 preceding siblings ...)
2014-10-02 9:08 ` redi at gcc dot gnu.org
@ 2014-10-09 18:05 ` jason at gcc dot gnu.org
2014-10-10 20:35 ` jason at gcc dot gnu.org
2014-10-10 20:38 ` jason at gcc dot gnu.org
5 siblings, 0 replies; 7+ messages in thread
From: jason at gcc dot gnu.org @ 2014-10-09 18:05 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63437
--- Comment #4 from Jason Merrill <jason at gcc dot gnu.org> ---
Author: jason
Date: Thu Oct 9 18:05:17 2014
New Revision: 216042
URL: https://gcc.gnu.org/viewcvs?rev=216042&root=gcc&view=rev
Log:
PR c++/63437
* cp-tree.h (REF_PARENTHESIZED_P): Also allow INDIRECT_REF.
* semantics.c (force_paren_expr): And set it.
* typeck.c (check_return_expr): And handle it.
Added:
trunk/gcc/testsuite/g++.dg/cpp1y/paren1.C
Modified:
trunk/gcc/cp/ChangeLog
trunk/gcc/cp/cp-tree.h
trunk/gcc/cp/semantics.c
trunk/gcc/cp/typeck.c
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/63437] [4.9/5 regression][C++14] Parenthesized "movable but not copyable" object doesn't compile in return statement
2014-10-02 2:26 [Bug c++/63437] New: [4.9/5 regression][C++14] Parenthesized "movable but not copyable" object doesn't compile in return statement flast at flast dot jp
` (3 preceding siblings ...)
2014-10-09 18:05 ` jason at gcc dot gnu.org
@ 2014-10-10 20:35 ` jason at gcc dot gnu.org
2014-10-10 20:38 ` jason at gcc dot gnu.org
5 siblings, 0 replies; 7+ messages in thread
From: jason at gcc dot gnu.org @ 2014-10-10 20:35 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63437
--- Comment #5 from Jason Merrill <jason at gcc dot gnu.org> ---
Author: jason
Date: Fri Oct 10 20:35:18 2014
New Revision: 216106
URL: https://gcc.gnu.org/viewcvs?rev=216106&root=gcc&view=rev
Log:
PR c++/63437
* cp-tree.h (REF_PARENTHESIZED_P): Also allow INDIRECT_REF.
* semantics.c (force_paren_expr): And set it.
* typeck.c (check_return_expr): And handle it.
Added:
branches/gcc-4_9-branch/gcc/testsuite/g++.dg/cpp1y/paren1.C
Modified:
branches/gcc-4_9-branch/gcc/cp/ChangeLog
branches/gcc-4_9-branch/gcc/cp/cp-tree.h
branches/gcc-4_9-branch/gcc/cp/semantics.c
branches/gcc-4_9-branch/gcc/cp/typeck.c
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/63437] [4.9/5 regression][C++14] Parenthesized "movable but not copyable" object doesn't compile in return statement
2014-10-02 2:26 [Bug c++/63437] New: [4.9/5 regression][C++14] Parenthesized "movable but not copyable" object doesn't compile in return statement flast at flast dot jp
` (4 preceding siblings ...)
2014-10-10 20:35 ` jason at gcc dot gnu.org
@ 2014-10-10 20:38 ` jason at gcc dot gnu.org
5 siblings, 0 replies; 7+ messages in thread
From: jason at gcc dot gnu.org @ 2014-10-10 20:38 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63437
Jason Merrill <jason at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
CC| |jason at gcc dot gnu.org
Resolution|--- |FIXED
Assignee|unassigned at gcc dot gnu.org |jason at gcc dot gnu.org
Target Milestone|--- |4.9.2
--- Comment #6 from Jason Merrill <jason at gcc dot gnu.org> ---
Fixed.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2014-10-10 20:38 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-10-02 2:26 [Bug c++/63437] New: [4.9/5 regression][C++14] Parenthesized "movable but not copyable" object doesn't compile in return statement flast at flast dot jp
2014-10-02 3:03 ` [Bug c++/63437] " pinskia at gcc dot gnu.org
2014-10-02 7:40 ` flast at flast dot jp
2014-10-02 9:08 ` redi at gcc dot gnu.org
2014-10-09 18:05 ` jason at gcc dot gnu.org
2014-10-10 20:35 ` jason at gcc dot gnu.org
2014-10-10 20:38 ` jason 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).