public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/49447] New: operator= (and compound assignment ops) does not perfectly forward
@ 2011-06-17  4:35 lucdanton at free dot fr
  2011-09-05  6:38 ` [Bug c++/49447] " daniel.kruegler at googlemail dot com
  2011-09-22 17:52 ` [Bug c++/49447] [C++0x] " paolo.carlini at oracle dot com
  0 siblings, 2 replies; 3+ messages in thread
From: lucdanton at free dot fr @ 2011-06-17  4:35 UTC (permalink / raw)
  To: gcc-bugs

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

           Summary: operator= (and compound assignment ops) does not
                    perfectly forward
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: lucdanton@free.fr


Created attachment 24549
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=24549
Minimal example

An operator= (or compound assignment operator) that perfectly forwards its
argument, like so:

template<typename T>
T&&
operator=(T&& t)
{ return std::forward<T>(t); }

does not behave exactly like a member will:

template<typename T>
T&&
member(T&& t)
{ return std::forward<T>(t); }

In particular, for some types (integral types it seems), when passed an lvalue
reference to const, operator= returns an rvalue reference to const, e.g. long
const& becomes long const&&. This does not happen for e.g. pointer types, class
types or float or double; or when the function is instead declared as e.g.
operator+ (but not operator+=) or as a regular member.

This is using:
gcc version 4.7.0 20110531 (experimental) [trunk revision 174470] (Debian
20110531-1)

Attached is an example which fails to compile from trying to take the address
of the result of operator= and from triggering a static_assert.


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

* [Bug c++/49447] operator= (and compound assignment ops) does not perfectly forward
  2011-06-17  4:35 [Bug c++/49447] New: operator= (and compound assignment ops) does not perfectly forward lucdanton at free dot fr
@ 2011-09-05  6:38 ` daniel.kruegler at googlemail dot com
  2011-09-22 17:52 ` [Bug c++/49447] [C++0x] " paolo.carlini at oracle dot com
  1 sibling, 0 replies; 3+ messages in thread
From: daniel.kruegler at googlemail dot com @ 2011-09-05  6:38 UTC (permalink / raw)
  To: gcc-bugs

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

Daniel Krügler <daniel.kruegler at googlemail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |daniel.kruegler at
                   |                            |googlemail dot com

--- Comment #1 from Daniel Krügler <daniel.kruegler at googlemail dot com> 2011-09-05 06:38:19 UTC ---
It seems that this problem had been fixed now. The example code successfully
compiles with gcc 4.7.0 20110903 (experimental).


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

* [Bug c++/49447] [C++0x] operator= (and compound assignment ops) does not perfectly forward
  2011-06-17  4:35 [Bug c++/49447] New: operator= (and compound assignment ops) does not perfectly forward lucdanton at free dot fr
  2011-09-05  6:38 ` [Bug c++/49447] " daniel.kruegler at googlemail dot com
@ 2011-09-22 17:52 ` paolo.carlini at oracle dot com
  1 sibling, 0 replies; 3+ messages in thread
From: paolo.carlini at oracle dot com @ 2011-09-22 17:52 UTC (permalink / raw)
  To: gcc-bugs

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

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
      Known to work|                            |4.7.0
         Resolution|                            |WORKSFORME
            Summary|operator= (and compound     |[C++0x] operator= (and
                   |assignment ops) does not    |compound assignment ops)
                   |perfectly forward           |does not perfectly forward

--- Comment #2 from Paolo Carlini <paolo.carlini at oracle dot com> 2011-09-22 17:43:02 UTC ---
Indeed.


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

end of thread, other threads:[~2011-09-22 17:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-06-17  4:35 [Bug c++/49447] New: operator= (and compound assignment ops) does not perfectly forward lucdanton at free dot fr
2011-09-05  6:38 ` [Bug c++/49447] " daniel.kruegler at googlemail dot com
2011-09-22 17:52 ` [Bug c++/49447] [C++0x] " paolo.carlini at oracle dot com

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).