[llvm-bugs] [Bug 32963] New: Incorrect implementation of LWG 2534

via llvm-bugs llvm-bugs at lists.llvm.org
Mon May 8 04:18:15 PDT 2017


https://bugs.llvm.org/show_bug.cgi?id=32963

            Bug ID: 32963
           Summary: Incorrect implementation of LWG 2534
           Product: libc++
           Version: 4.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: All Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: zilla at kayari.org
                CC: llvm-bugs at lists.llvm.org, mclow.lists at gmail.com

#include <iostream>

int main()
{
    std::ostream& os = std::move(std::cout) << "http://wg21.link/lwg2534";
    os << '\n';
}


prog.cc:5:19: error: non-const lvalue reference to type 'basic_ostream<...>'
cannot bind to a temporary of type 'basic_ostream<...>'
    std::ostream& os = std::move(std::cout) << "http://wg21.link/lwg2534";
                  ^    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The return type should be an lvalue reference.

The SFINAE constraint on the operator<< for rvalue streams also seem wrong.
This shouldn't compile because the constraint is not met:

#include <ostream>

struct X : std::ios_base { };
struct Y { };

template<typename T, typename U, typename = void>
  struct is_streamable
  : std::false_type { };

template<typename T, typename U>
  struct is_streamable<T, U, decltype(void(), std::declval<T>() <<
std::declval<U>())>
  : std::true_type { };

static_assert( !is_streamable<X, Y>::value, "" );

decltype(std::declval<X>() << std::declval<Y>()) f();
const auto& ff = f();

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20170508/0fb9888e/attachment.html>


More information about the llvm-bugs mailing list