[LLVMbugs] [Bug 13311] New: [C++11] cannot return rvalue reference to function type

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon Jul 9 13:02:51 PDT 2012


             Bug #: 13311
           Summary: [C++11] cannot return rvalue reference to function
           Product: clang
           Version: trunk
          Platform: PC
        OS/Version: Windows NT
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++11
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: eric at boostpro.com
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    Classification: Unclassified

The following code fails to compile:

  #include <type_traits>
  void bar() {}
  void (&&foo())() { return static_cast<void (&&)()>(bar); }
  static_assert(std::is_same<decltype(foo()), void (&&)()>::value, "");

In my understanding, rvalue references to function types are allowed, and clang
seems to agree. However, clang refuses to return one. Instead, it gets turned
into an lvalue reference to function type. The following succeeds:

  // Shouldn't compile but does, IIUC
  static_assert(std::is_same<decltype(foo()), void (&)()>::value, "");

Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.

More information about the llvm-bugs mailing list