<html>
    <head>
      <base href="http://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - Non conformance caused by _Stream&& operator<<(_Stream&& __os, const _Tp& __x)"
   href="http://llvm.org/bugs/show_bug.cgi?id=20596">20596</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Non conformance caused by _Stream&& operator<<(_Stream&& __os, const _Tp& __x)
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libc++
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>Macintosh
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>MacOS X
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>All Bugs
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>gpakosz@pempek.net
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu, mclow.lists@gmail.com
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>The following snippets compiles successfully with clang++ on MacOS X 10.9.4

$ clang --version
Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn)
Target: x86_64-apple-darwin13.3.0
Thread model: posix

---
#include <string>
#include <iostream>
#include <sstream>

void print(const std::string& s)
{
  std::cout << s << std::endl;
}

int main()
{
  int v = 1;
  print((std::ostringstream() << "value: " << v).str());
  return 0;
}

The type of ostringstream() << "value: " is rvalue ostringstream.
While it should be lvalue ostream.

According to the addition of the following operator in C++11,
template< class CharT, class Traits, class T >
basic_ostream< CharT, Traits >& operator<<( basic_ostream<CharT,Traits>&& os, 
                                            const T& value );

The code sample above should be written the following way:
print(static_cast<std::ostringstream&>(std::ostringstream() << "value: " <<
v).str());

But then, clang++ with libc++ returns the following error message:
$ clang++ --std=c++11 -g main.cpp
main.cpp:13:9: error: non-const lvalue reference to type
'basic_ostringstream<[3 * ...]>' cannot bind to a temporary of type
'basic_ostringstream<[3 * ...]>'
  print(static_cast<std::ostringstream&>(std::ostringstream() << "value: " <<
v).str());


---
In the end, the most reliable way to achieve that one-liner is to write:
print(static_cast<std::ostringstream&>(std::ostringstream().flush() << "value:
" << v).str());

Now it compiles successfully and works as expected with G++, clang++ (libstdc++
or libc++) and also MSVC++ 2012. Either in C++2003 or C++11. Note that in the
case of MSVC++ 2012, I went for flush() instead of seekp(0) because seekp(0) on
a newly constructed ostringstream sets the failbit...</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>