public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/34022] New: Rvalue references and std::forward() broken with built-in types
@ 2007-11-08 1:26 eric dot niebler at gmail dot com
2007-11-08 1:59 ` [Bug c++/34022] " pinskia at gcc dot gnu dot org
` (7 more replies)
0 siblings, 8 replies; 10+ messages in thread
From: eric dot niebler at gmail dot com @ 2007-11-08 1:26 UTC (permalink / raw)
To: gcc-bugs
Compile the following program with -std=c++0x. In my understanding, the two
printed addresses should be the same. They are when I invoke foo() with a class
type, but not with built-in types like char.
This is with the latest g++ built from SVN.
#include <cstdio>
#include <utility>
template<typename T> void bar(T &&t)
{
std::printf("%p\n", &t);
}
template<typename T> void foo(T &&t)
{
std::printf("%p\n", &t);
bar(std::forward<T>(t));
}
struct S {};
int main()
{
foo('a'); // WRONG, prints 2 different addresses
foo(S()); // OK, prints the same address twice
}
--
Summary: Rvalue references and std::forward() broken with built-
in types
Product: gcc
Version: 4.3.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: eric dot niebler at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34022
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/34022] Rvalue references and std::forward() broken with built-in types
2007-11-08 1:26 [Bug c++/34022] New: Rvalue references and std::forward() broken with built-in types eric dot niebler at gmail dot com
@ 2007-11-08 1:59 ` pinskia at gcc dot gnu dot org
2007-11-08 2:01 ` pinskia at gcc dot gnu dot org
` (6 subsequent siblings)
7 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-11-08 1:59 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from pinskia at gcc dot gnu dot org 2007-11-08 01:59 -------
D.3322 = 97;
printf (&"%p\n"[0], &D.3322);
D.3373 = D.3322;
printf (&"%p\n"[0], &D.3373);
D.3323 = {};
printf (&"%p\n"[0], &D.3323);
printf (&"%p\n"[0], &D.3323);
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34022
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/34022] Rvalue references and std::forward() broken with built-in types
2007-11-08 1:26 [Bug c++/34022] New: Rvalue references and std::forward() broken with built-in types eric dot niebler at gmail dot com
2007-11-08 1:59 ` [Bug c++/34022] " pinskia at gcc dot gnu dot org
@ 2007-11-08 2:01 ` pinskia at gcc dot gnu dot org
2007-11-16 20:11 ` [Bug c++/34022] C++0x: rvalue " dgregor at gcc dot gnu dot org
` (5 subsequent siblings)
7 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-11-08 2:01 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from pinskia at gcc dot gnu dot org 2007-11-08 02:01 -------
<<cleanup_point <<< Unknown tree: expr_stmt
bar ((char &) &TARGET_EXPR <D.3338, *forward ((char &) (char *) t)>) >>>
>>;
vs:
<<cleanup_point <<< Unknown tree: expr_stmt
bar ((struct S &) (struct S *) forward ((struct S &) (struct S *) t)) >>>
>>;
--
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever Confirmed|0 |1
Keywords| |wrong-code
Last reconfirmed|0000-00-00 00:00:00 |2007-11-08 02:01:11
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34022
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/34022] C++0x: rvalue references and std::forward() broken with built-in types
2007-11-08 1:26 [Bug c++/34022] New: Rvalue references and std::forward() broken with built-in types eric dot niebler at gmail dot com
2007-11-08 1:59 ` [Bug c++/34022] " pinskia at gcc dot gnu dot org
2007-11-08 2:01 ` pinskia at gcc dot gnu dot org
@ 2007-11-16 20:11 ` dgregor at gcc dot gnu dot org
2007-11-18 14:15 ` dgregor at gcc dot gnu dot org
` (4 subsequent siblings)
7 siblings, 0 replies; 10+ messages in thread
From: dgregor at gcc dot gnu dot org @ 2007-11-16 20:11 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from dgregor at gcc dot gnu dot org 2007-11-16 20:10 -------
I'm working on it
--
dgregor at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|unassigned at gcc dot gnu |dgregor at gcc dot gnu dot
|dot org |org
Status|NEW |ASSIGNED
Last reconfirmed|2007-11-08 02:01:11 |2007-11-16 20:10:50
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34022
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/34022] C++0x: rvalue references and std::forward() broken with built-in types
2007-11-08 1:26 [Bug c++/34022] New: Rvalue references and std::forward() broken with built-in types eric dot niebler at gmail dot com
` (2 preceding siblings ...)
2007-11-16 20:11 ` [Bug c++/34022] C++0x: rvalue " dgregor at gcc dot gnu dot org
@ 2007-11-18 14:15 ` dgregor at gcc dot gnu dot org
2008-03-19 13:12 ` dgregor at gcc dot gnu dot org
` (3 subsequent siblings)
7 siblings, 0 replies; 10+ messages in thread
From: dgregor at gcc dot gnu dot org @ 2007-11-18 14:15 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from dgregor at gcc dot gnu dot org 2007-11-18 14:15 -------
On further reading into the standard, I believe GCC is doing the right thing.
8.5.3p5 is very specific in saying that one can only bind a reference to an
rvalue if the type of the rvalue is of class type. Otherwise, a temporary is
being created.
If this isn't what Howard intended or expected, we need to bring this to the
committee.
--
dgregor at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |SUSPENDED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34022
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/34022] C++0x: rvalue references and std::forward() broken with built-in types
2007-11-08 1:26 [Bug c++/34022] New: Rvalue references and std::forward() broken with built-in types eric dot niebler at gmail dot com
` (3 preceding siblings ...)
2007-11-18 14:15 ` dgregor at gcc dot gnu dot org
@ 2008-03-19 13:12 ` dgregor at gcc dot gnu dot org
2008-12-02 17:54 ` jason at gcc dot gnu dot org
` (2 subsequent siblings)
7 siblings, 0 replies; 10+ messages in thread
From: dgregor at gcc dot gnu dot org @ 2008-03-19 13:12 UTC (permalink / raw)
To: gcc-bugs
------- Comment #5 from dgregor at gcc dot gnu dot org 2008-03-19 13:12 -------
This is core issue 664:
http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#664
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34022
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/34022] C++0x: rvalue references and std::forward() broken with built-in types
2007-11-08 1:26 [Bug c++/34022] New: Rvalue references and std::forward() broken with built-in types eric dot niebler at gmail dot com
` (4 preceding siblings ...)
2008-03-19 13:12 ` dgregor at gcc dot gnu dot org
@ 2008-12-02 17:54 ` jason at gcc dot gnu dot org
2009-06-02 14:14 ` jwakely dot gcc at gmail dot com
2009-08-01 9:45 ` paolo dot carlini at oracle dot com
7 siblings, 0 replies; 10+ messages in thread
From: jason at gcc dot gnu dot org @ 2008-12-02 17:54 UTC (permalink / raw)
To: gcc-bugs
--
jason at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|dgregor at gcc dot gnu dot |unassigned at gcc dot gnu
|org |dot org
Status|SUSPENDED |NEW
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34022
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/34022] C++0x: rvalue references and std::forward() broken with built-in types
2007-11-08 1:26 [Bug c++/34022] New: Rvalue references and std::forward() broken with built-in types eric dot niebler at gmail dot com
` (5 preceding siblings ...)
2008-12-02 17:54 ` jason at gcc dot gnu dot org
@ 2009-06-02 14:14 ` jwakely dot gcc at gmail dot com
2009-08-01 9:45 ` paolo dot carlini at oracle dot com
7 siblings, 0 replies; 10+ messages in thread
From: jwakely dot gcc at gmail dot com @ 2009-06-02 14:14 UTC (permalink / raw)
To: gcc-bugs
------- Comment #6 from jwakely dot gcc at gmail dot com 2009-06-02 14:14 -------
*** Bug 40295 has been marked as a duplicate of this bug. ***
--
jwakely dot gcc at gmail dot com changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jwakely dot gcc at gmail dot
| |com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34022
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/34022] C++0x: rvalue references and std::forward() broken with built-in types
2007-11-08 1:26 [Bug c++/34022] New: Rvalue references and std::forward() broken with built-in types eric dot niebler at gmail dot com
` (6 preceding siblings ...)
2009-06-02 14:14 ` jwakely dot gcc at gmail dot com
@ 2009-08-01 9:45 ` paolo dot carlini at oracle dot com
7 siblings, 0 replies; 10+ messages in thread
From: paolo dot carlini at oracle dot com @ 2009-08-01 9:45 UTC (permalink / raw)
To: gcc-bugs
------- Comment #7 from paolo dot carlini at oracle dot com 2009-08-01 09:45 -------
Appears also fixed by the fix for PR 40486. Otherwise, please reopen.
--
paolo dot carlini at oracle dot com changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |FIXED
Target Milestone|--- |4.5.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34022
^ permalink raw reply [flat|nested] 10+ messages in thread
[parent not found: <bug-34022-4@http.gcc.gnu.org/bugzilla/>]
end of thread, other threads:[~2010-11-30 20:32 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-11-08 1:26 [Bug c++/34022] New: Rvalue references and std::forward() broken with built-in types eric dot niebler at gmail dot com
2007-11-08 1:59 ` [Bug c++/34022] " pinskia at gcc dot gnu dot org
2007-11-08 2:01 ` pinskia at gcc dot gnu dot org
2007-11-16 20:11 ` [Bug c++/34022] C++0x: rvalue " dgregor at gcc dot gnu dot org
2007-11-18 14:15 ` dgregor at gcc dot gnu dot org
2008-03-19 13:12 ` dgregor at gcc dot gnu dot org
2008-12-02 17:54 ` jason at gcc dot gnu dot org
2009-06-02 14:14 ` jwakely dot gcc at gmail dot com
2009-08-01 9:45 ` paolo dot carlini at oracle dot com
[not found] <bug-34022-4@http.gcc.gnu.org/bugzilla/>
2010-11-30 20:56 ` redi 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).