Bug 35153 - [C++0x] Taking address of result of calling function returning rvalue reference should not compile.
Summary: [C++0x] Taking address of result of calling function returning rvalue referen...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.3.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL: http://gcc.gnu.org/ml/gcc-patches/200...
Keywords: accepts-invalid
Depends on:
Blocks:
 
Reported: 2008-02-10 08:36 UTC by Eelis
Modified: 2011-09-29 00:17 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2008-02-15 19:55:06


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Eelis 2008-02-10 08:36:09 UTC
Consider:

  int && f();
  void g() { &(f()); }

GCC accepts, but shouldn't, because by 5.3.1p2 (in n2461) the operand of unary & must be an lvalue, and by 5p6 (f()) is an rvalue.

I'm using g++ (GCC) 4.3.0 20080106 (experimental).
Comment 1 dgregor 2008-02-15 19:55:06 UTC
After discussing this with Howard Hinnant, we agree that it is a bug. I'll handle it.
Comment 2 andreasmeier80 2008-02-16 03:39:06 UTC
Patch at http://gcc.gnu.org/ml/gcc-patches/2008-02/msg00584.html
Comment 3 Paolo Carlini 2011-09-29 00:17:17 UTC
Fixed in 4.6.x.