[Bug c++/34022] New: Rvalue references and std::forward() broken with built-in types
eric dot niebler at gmail dot com
gcc-bugzilla@gcc.gnu.org
Thu Nov 8 01:26:00 GMT 2007
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
More information about the Gcc-bugs
mailing list