This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/49389] New: [C++0x] Wrong value category for pointer-to-member expression with rvalue object expression
- From: "daniel.kruegler at googlemail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 13 Jun 2011 11:19:27 +0000
- Subject: [Bug c++/49389] New: [C++0x] Wrong value category for pointer-to-member expression with rvalue object expression
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49389
Summary: [C++0x] Wrong value category for pointer-to-member
expression with rvalue object expression
Product: gcc
Version: 4.7.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: daniel.kruegler@googlemail.com
CC: jason@redhat.com
gcc 4.7.0 20110611 (experimental) in C++0x mode rejects the following program
at the line marked with #:
//----
template<class T>
T&& val();
struct A {};
typedef decltype(val<A>().*val<int A::*>()) type;
template<class>
struct assert_type;
template<>
struct assert_type<int&&> {};
assert_type<type> test; // #
//----
"error: aggregate 'assert_type<int&> test' has incomplete type and cannot be
defined"
Further testing reveals that the deduced type is 'int&' instead of 'int&&'.
According to my reading of 5.5 [expr.mptr.oper] p6:
"The result of a .* expression whose second operand is a pointer to a data
member is of the same value category (3.10) as its first operand."
we have an xvalue expression val<A>() as the first operand, which should result
in an xvalue expression category for the complete pointer-to-member expression.
Referring to 7.1.6.2 [dcl.type.simple] p4, we should fall into bullet 2:
"otherwise, if e is an xvalue, decltype(e) is T&&, where T is the type of e;"
which should have the effect of returning int&&, not int&. Therefore gcc should
accept this program.