From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22255 invoked by alias); 30 Oct 2013 12:02:57 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 22208 invoked by uid 48); 30 Oct 2013 12:02:53 -0000 From: "sir_nawaz959 at yahoo dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/58924] New: Non-member invocation of overload of operator<< when the first argument is a temporary of type std::stringstream Date: Wed, 30 Oct 2013 12:02:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: unknown X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: sir_nawaz959 at yahoo dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2013-10/txt/msg02135.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58924 Bug ID: 58924 Summary: Non-member invocation of overload of operator<< when the first argument is a temporary of type std::stringstream Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: sir_nawaz959 at yahoo dot com I'm using GCC-4.8.1 in C++11 Mode. Consider this code, #include #include int main() { auto s = static_cast(std::stringstream() << "XYZ" << "ABC").str(); std::cout << s << std::endl; } Actual (incorrect) output: XYZABC The expected output is an address following by ABC, something like this: 0x400e83ABC Because `std::stringstream()` is a temporary, so the first invocation of `operator<<` must resolve to a member function (taking void* as argument) which would print the address, and then the non-member function should be invoked for the second `<<`. Note that this works as expected when I don't use `-std=C++11` (of course, in that case I use `std::string` instead of `auto`).