public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/59823] New: conversion operator to const X& causes copy-construction of temporary
@ 2014-01-15 11:27 redi at gcc dot gnu.org
2014-01-15 11:29 ` [Bug c++/59823] [4.7/4.8/4.9 Regression] " redi at gcc dot gnu.org
` (7 more replies)
0 siblings, 8 replies; 9+ messages in thread
From: redi at gcc dot gnu.org @ 2014-01-15 11:27 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59823
Bug ID: 59823
Summary: conversion operator to const X& causes
copy-construction of temporary
Product: gcc
Version: 4.9.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: redi at gcc dot gnu.org
extern "C" int puts(const char*);
struct X
{
X() { }
X(const X&) { puts("copy"); }
X(X&&) { puts("move"); }
X& operator=(const X&) { puts("copy assign"); return *this; }
X& operator=(X&&) { puts("move assign"); return *this; }
};
struct wrap
{
wrap(const X& x) : wrapped(&x) { }
const X* wrapped;
operator const X&() const { return *wrapped; }
};
int main()
{
X x1, x2;
wrap w(x2);
x1 = w;
}
When compiled with -std=c++11 the expected output is:
copy assign
but G++ produces:
copy
move assign
It seems that on the last line of main() G++ incorrectly creates a
temporary, doing "x1 = X(w)" instead of "x1 = w"
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/59823] [4.7/4.8/4.9 Regression] conversion operator to const X& causes copy-construction of temporary
2014-01-15 11:27 [Bug c++/59823] New: conversion operator to const X& causes copy-construction of temporary redi at gcc dot gnu.org
@ 2014-01-15 11:29 ` redi at gcc dot gnu.org
2014-01-27 20:09 ` jason at gcc dot gnu.org
` (6 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: redi at gcc dot gnu.org @ 2014-01-15 11:29 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59823
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Known to work| |4.6.4
Summary|conversion operator to |[4.7/4.8/4.9 Regression]
|const X& causes |conversion operator to
|copy-construction of |const X& causes
|temporary |copy-construction of
| |temporary
Known to fail| |4.7.4, 4.8.2, 4.9.0
--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
GCC 4.6 correctly printed "copy assign" so this is a regression.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/59823] [4.7/4.8/4.9 Regression] conversion operator to const X& causes copy-construction of temporary
2014-01-15 11:27 [Bug c++/59823] New: conversion operator to const X& causes copy-construction of temporary redi at gcc dot gnu.org
2014-01-15 11:29 ` [Bug c++/59823] [4.7/4.8/4.9 Regression] " redi at gcc dot gnu.org
@ 2014-01-27 20:09 ` jason at gcc dot gnu.org
2014-01-28 4:32 ` jason at gcc dot gnu.org
` (5 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: jason at gcc dot gnu.org @ 2014-01-27 20:09 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59823
Jason Merrill <jason at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |ASSIGNED
Last reconfirmed| |2014-01-27
CC| |jason at gcc dot gnu.org
Assignee|unassigned at gcc dot gnu.org |jason at gcc dot gnu.org
Ever confirmed|0 |1
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/59823] [4.7/4.8/4.9 Regression] conversion operator to const X& causes copy-construction of temporary
2014-01-15 11:27 [Bug c++/59823] New: conversion operator to const X& causes copy-construction of temporary redi at gcc dot gnu.org
2014-01-15 11:29 ` [Bug c++/59823] [4.7/4.8/4.9 Regression] " redi at gcc dot gnu.org
2014-01-27 20:09 ` jason at gcc dot gnu.org
@ 2014-01-28 4:32 ` jason at gcc dot gnu.org
2014-01-28 14:03 ` jason at gcc dot gnu.org
` (4 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: jason at gcc dot gnu.org @ 2014-01-28 4:32 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59823
--- Comment #2 from Jason Merrill <jason at gcc dot gnu.org> ---
Author: jason
Date: Tue Jan 28 04:31:39 2014
New Revision: 207170
URL: http://gcc.gnu.org/viewcvs?rev=207170&root=gcc&view=rev
Log:
PR c++/59823
Core DR 1138
* call.c (reference_binding): Pass LOOKUP_NO_TEMP_BIND for
list-initialization. A conversion to rvalue ref that involves
an lvalue-rvalue conversion is bad.
(convert_like_real): Give helpful error message.
Added:
trunk/gcc/testsuite/g++.dg/cpp0x/overload3.C
Modified:
trunk/gcc/cp/ChangeLog
trunk/gcc/cp/call.c
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/59823] [4.7/4.8/4.9 Regression] conversion operator to const X& causes copy-construction of temporary
2014-01-15 11:27 [Bug c++/59823] New: conversion operator to const X& causes copy-construction of temporary redi at gcc dot gnu.org
` (2 preceding siblings ...)
2014-01-28 4:32 ` jason at gcc dot gnu.org
@ 2014-01-28 14:03 ` jason at gcc dot gnu.org
2014-04-22 11:38 ` [Bug c++/59823] [4.7/4.8 " jakub at gcc dot gnu.org
` (3 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: jason at gcc dot gnu.org @ 2014-01-28 14:03 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59823
Jason Merrill <jason at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |4.9.0
--- Comment #3 from Jason Merrill <jason at gcc dot gnu.org> ---
Fixed in 4.9. Will apply to 4.8 later if no problems arise.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/59823] [4.7/4.8 Regression] conversion operator to const X& causes copy-construction of temporary
2014-01-15 11:27 [Bug c++/59823] New: conversion operator to const X& causes copy-construction of temporary redi at gcc dot gnu.org
` (3 preceding siblings ...)
2014-01-28 14:03 ` jason at gcc dot gnu.org
@ 2014-04-22 11:38 ` jakub at gcc dot gnu.org
2014-04-22 11:48 ` redi at gcc dot gnu.org
` (2 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu.org @ 2014-04-22 11:38 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59823
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|4.9.0 |4.9.1
--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
GCC 4.9.0 has been released
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/59823] [4.7/4.8 Regression] conversion operator to const X& causes copy-construction of temporary
2014-01-15 11:27 [Bug c++/59823] New: conversion operator to const X& causes copy-construction of temporary redi at gcc dot gnu.org
` (4 preceding siblings ...)
2014-04-22 11:38 ` [Bug c++/59823] [4.7/4.8 " jakub at gcc dot gnu.org
@ 2014-04-22 11:48 ` redi at gcc dot gnu.org
2014-08-01 18:34 ` [Bug c++/59823] [4.8 " jason at gcc dot gnu.org
2014-08-01 18:36 ` jason at gcc dot gnu.org
7 siblings, 0 replies; 9+ messages in thread
From: redi at gcc dot gnu.org @ 2014-04-22 11:48 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59823
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Known to work| |4.9.0
Target Milestone|4.9.1 |4.9.0
Known to fail|4.9.0 |
--- Comment #5 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Resetting target milestone, the fix is already in 4.9.0
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/59823] [4.8 Regression] conversion operator to const X& causes copy-construction of temporary
2014-01-15 11:27 [Bug c++/59823] New: conversion operator to const X& causes copy-construction of temporary redi at gcc dot gnu.org
` (5 preceding siblings ...)
2014-04-22 11:48 ` redi at gcc dot gnu.org
@ 2014-08-01 18:34 ` jason at gcc dot gnu.org
2014-08-01 18:36 ` jason at gcc dot gnu.org
7 siblings, 0 replies; 9+ messages in thread
From: jason at gcc dot gnu.org @ 2014-08-01 18:34 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59823
--- Comment #6 from Jason Merrill <jason at gcc dot gnu.org> ---
Author: jason
Date: Fri Aug 1 18:33:54 2014
New Revision: 213502
URL: https://gcc.gnu.org/viewcvs?rev=213502&root=gcc&view=rev
Log:
PR c++/59823
Core DR 1138
* call.c (reference_binding): Pass LOOKUP_NO_TEMP_BIND for
list-initialization. A conversion to rvalue ref that involves
an lvalue-rvalue conversion is bad.
(convert_like_real): Give helpful error message.
Added:
branches/gcc-4_8-branch/gcc/testsuite/g++.dg/cpp0x/overload3.C
Modified:
branches/gcc-4_8-branch/gcc/cp/ChangeLog
branches/gcc-4_8-branch/gcc/cp/call.c
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/59823] [4.8 Regression] conversion operator to const X& causes copy-construction of temporary
2014-01-15 11:27 [Bug c++/59823] New: conversion operator to const X& causes copy-construction of temporary redi at gcc dot gnu.org
` (6 preceding siblings ...)
2014-08-01 18:34 ` [Bug c++/59823] [4.8 " jason at gcc dot gnu.org
@ 2014-08-01 18:36 ` jason at gcc dot gnu.org
7 siblings, 0 replies; 9+ messages in thread
From: jason at gcc dot gnu.org @ 2014-08-01 18:36 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59823
Jason Merrill <jason at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution|--- |FIXED
Target Milestone|4.9.0 |4.8.4
--- Comment #7 from Jason Merrill <jason at gcc dot gnu.org> ---
Fixed for 4.8.4.
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2014-08-01 18:36 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-01-15 11:27 [Bug c++/59823] New: conversion operator to const X& causes copy-construction of temporary redi at gcc dot gnu.org
2014-01-15 11:29 ` [Bug c++/59823] [4.7/4.8/4.9 Regression] " redi at gcc dot gnu.org
2014-01-27 20:09 ` jason at gcc dot gnu.org
2014-01-28 4:32 ` jason at gcc dot gnu.org
2014-01-28 14:03 ` jason at gcc dot gnu.org
2014-04-22 11:38 ` [Bug c++/59823] [4.7/4.8 " jakub at gcc dot gnu.org
2014-04-22 11:48 ` redi at gcc dot gnu.org
2014-08-01 18:34 ` [Bug c++/59823] [4.8 " jason at gcc dot gnu.org
2014-08-01 18:36 ` 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).