public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/40682]  New: Require direct binding of short-lived references to rvalues
@ 2009-07-08 11:04 dragan at plusplus dot co dot yu
  2009-07-08 11:42 ` [Bug c++/40682] [C++0x] " paolo dot carlini at oracle dot com
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: dragan at plusplus dot co dot yu @ 2009-07-08 11:04 UTC (permalink / raw)
  To: gcc-bugs

In a recent discussion on comp.std.c++
"rvalue references returned from a function",
as pointed by Niels Dekker and Micael Dark,
a defect report:

  http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#391

was accepted into C++0x WP. This has a significant impact on GCC.

The current behavior also creates a problem with the following:

  struct R {
    R(const R &);
  };

  R && func();

  int main() {
    R const & r1 = func();
    R &&      r2 = func();
  }

Both r1 and r2 will be bound to a temporary which will be
created by copying (or if available - moving) the returned
rvalue. This is invalid according to the mentioned changes.


-- 
           Summary: Require direct binding of short-lived references to
                    rvalues
           Product: gcc
           Version: 4.5.0
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: dragan at plusplus dot co dot yu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40682


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug c++/40682] [C++0x] Require direct binding of short-lived references to rvalues
  2009-07-08 11:04 [Bug c++/40682] New: Require direct binding of short-lived references to rvalues dragan at plusplus dot co dot yu
@ 2009-07-08 11:42 ` paolo dot carlini at oracle dot com
  2009-07-08 12:38 ` dragan at plusplus dot co dot yu
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: paolo dot carlini at oracle dot com @ 2009-07-08 11:42 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from paolo dot carlini at oracle dot com  2009-07-08 11:41 -------
Note, in general work on C++0x features doesn't really belong to Bugzilla,
unless existing code crashes on new testcases, things like that. You understand
that in general the situation would otherwise quickly explode. About this
specific issue, I suspect we even have something already open. Maybe Jon can
help...


-- 

paolo dot carlini at oracle dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jwakely dot gcc at gmail dot
                   |                            |com
            Summary|Require direct binding of   |[C++0x] Require direct
                   |short-lived references to   |binding of short-lived
                   |rvalues                     |references to rvalues


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40682


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug c++/40682] [C++0x] Require direct binding of short-lived references to rvalues
  2009-07-08 11:04 [Bug c++/40682] New: Require direct binding of short-lived references to rvalues dragan at plusplus dot co dot yu
  2009-07-08 11:42 ` [Bug c++/40682] [C++0x] " paolo dot carlini at oracle dot com
@ 2009-07-08 12:38 ` dragan at plusplus dot co dot yu
  2009-07-08 12:48 ` paolo dot carlini at oracle dot com
  2009-10-07 19:46 ` jason at gcc dot gnu dot org
  3 siblings, 0 replies; 5+ messages in thread
From: dragan at plusplus dot co dot yu @ 2009-07-08 12:38 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from dragan at plusplus dot co dot yu  2009-07-08 12:38 -------
Although this is a feature request in the context that the old behavior
was correctly implemented and it will be different in C++0x, it still presents
a bug in the current C++0x implementation. It creates copies of
objects that are returned by a rvalue reference, which would be wrong.
I wasn't _really_ trying to request a new functionality, although
I understand your concern.

However, IMHO in this particular case we are talking about one of
the most fundamental features (binding a reference). This change
could also expose possible bugs in the (user and library) code that
relies on creation of a temporary, which even in C++03 is not
considered a portable code. Don't tell me you'd rather deal with
the issue after all the other C++0x stuff gets implemented...

Anyway, my motive was to help the development of GCC. Personally,
I didn't and will not rely on either of the two behaviors, but
will try to write code that works in both situations.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40682


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug c++/40682] [C++0x] Require direct binding of short-lived references to rvalues
  2009-07-08 11:04 [Bug c++/40682] New: Require direct binding of short-lived references to rvalues dragan at plusplus dot co dot yu
  2009-07-08 11:42 ` [Bug c++/40682] [C++0x] " paolo dot carlini at oracle dot com
  2009-07-08 12:38 ` dragan at plusplus dot co dot yu
@ 2009-07-08 12:48 ` paolo dot carlini at oracle dot com
  2009-10-07 19:46 ` jason at gcc dot gnu dot org
  3 siblings, 0 replies; 5+ messages in thread
From: paolo dot carlini at oracle dot com @ 2009-07-08 12:48 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from paolo dot carlini at oracle dot com  2009-07-08 12:47 -------
To be clear, I'm not telling you anything specific about the development
process. Actually, that's exactly the point, this is ongoing development of
experimental features, no guarantees, no guarantees of perfect adherence to the
last public draft, etc.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40682


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug c++/40682] [C++0x] Require direct binding of short-lived references to rvalues
  2009-07-08 11:04 [Bug c++/40682] New: Require direct binding of short-lived references to rvalues dragan at plusplus dot co dot yu
                   ` (2 preceding siblings ...)
  2009-07-08 12:48 ` paolo dot carlini at oracle dot com
@ 2009-10-07 19:46 ` jason at gcc dot gnu dot org
  3 siblings, 0 replies; 5+ messages in thread
From: jason at gcc dot gnu dot org @ 2009-10-07 19:46 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from jason at gcc dot gnu dot org  2009-10-07 19:45 -------
Neither 4.4.1 nor 4.5 try to call the copy constructor in your example; I
believe I fixed this issue in 4.4.


-- 

jason at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |FIXED


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40682


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2009-10-07 19:46 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-07-08 11:04 [Bug c++/40682] New: Require direct binding of short-lived references to rvalues dragan at plusplus dot co dot yu
2009-07-08 11:42 ` [Bug c++/40682] [C++0x] " paolo dot carlini at oracle dot com
2009-07-08 12:38 ` dragan at plusplus dot co dot yu
2009-07-08 12:48 ` paolo dot carlini at oracle dot com
2009-10-07 19:46 ` jason at gcc dot gnu dot 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).