public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/58924] New: Non-member invocation of overload of operator<< when the first argument is a temporary of type std::stringstream
@ 2013-10-30 12:02 sir_nawaz959 at yahoo dot com
2013-10-30 13:09 ` [Bug c++/58924] " fanael4 at gmail dot com
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: sir_nawaz959 at yahoo dot com @ 2013-10-30 12:02 UTC (permalink / raw)
To: gcc-bugs
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 <sstream>
#include <iostream>
int main()
{
auto s = static_cast<std::stringstream&>(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`).
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/58924] Non-member invocation of overload of operator<< when the first argument is a temporary of type std::stringstream
2013-10-30 12:02 [Bug c++/58924] New: Non-member invocation of overload of operator<< when the first argument is a temporary of type std::stringstream sir_nawaz959 at yahoo dot com
@ 2013-10-30 13:09 ` fanael4 at gmail dot com
2013-10-30 13:37 ` daniel.kruegler at googlemail dot com
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: fanael4 at gmail dot com @ 2013-10-30 13:09 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58924
Fanael <fanael4 at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |fanael4 at gmail dot com
--- Comment #1 from Fanael <fanael4 at gmail dot com> ---
That's expected behavior AFAIU. 'operator<<(basic_ostream<charT, traits>&& os,
const T& x)' is a better match for const char[K] than
'basic_ostream<charT,traits>& basic_ostream<charT,traits>::operator<<(const
void* p)', hence the former gets called, which then forwards the arguments to
'operator<<(basic_ostream<charT, traits>&& os, const charT* x)'.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/58924] Non-member invocation of overload of operator<< when the first argument is a temporary of type std::stringstream
2013-10-30 12:02 [Bug c++/58924] New: Non-member invocation of overload of operator<< when the first argument is a temporary of type std::stringstream sir_nawaz959 at yahoo dot com
2013-10-30 13:09 ` [Bug c++/58924] " fanael4 at gmail dot com
@ 2013-10-30 13:37 ` daniel.kruegler at googlemail dot com
2013-10-30 13:48 ` [Bug libstdc++/58924] " redi at gcc dot gnu.org
2013-10-30 13:55 ` sir_nawaz959 at yahoo dot com
3 siblings, 0 replies; 5+ messages in thread
From: daniel.kruegler at googlemail dot com @ 2013-10-30 13:37 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58924
--- Comment #3 from Daniel Krügler <daniel.kruegler at googlemail dot com> ---
(In reply to Fanael from comment #1)
I agree with Fanael: It is supposed to be that way in C++11 because of the
provided stream-rvalue support via
template <class charT, class traits, class T>
basic_ostream<charT, traits>&
operator<<(basic_ostream<charT, traits>&& os, const T& x);
>From gcc-bugs-return-433048-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Wed Oct 30 13:40:43 2013
Return-Path: <gcc-bugs-return-433048-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 13854 invoked by alias); 30 Oct 2013 13:40:43 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 13820 invoked by uid 48); 30 Oct 2013 13:40:39 -0000
From: "rguenth at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug rtl-optimization/58384] [4.9 regression] Runfail on spec2000/253.perlbmk if lto and pre-reload scheduler is used on x86 after r200133.
Date: Wed, 30 Oct 2013 13:40:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: rtl-optimization
X-Bugzilla-Version: 4.9.0
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: rguenth at gcc dot gnu.org
X-Bugzilla-Status: WAITING
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: 4.9.0
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields: bug_status cf_reconfirmed_on everconfirmed
Message-ID: <bug-58384-4-6IUBt8W2C5@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-58384-4@http.gcc.gnu.org/bugzilla/>
References: <bug-58384-4@http.gcc.gnu.org/bugzilla/>
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/msg02192.txt.bz2
Content-length: 612
http://gcc.gnu.org/bugzilla/show_bug.cgi?idX384
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |WAITING
Last reconfirmed| |2013-10-30
Ever confirmed|0 |1
--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
Is it maybe fixed by the fix for PR58831? I can't seem to pattern match
the assembler generated by trunk with your description anymore.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug libstdc++/58924] Non-member invocation of overload of operator<< when the first argument is a temporary of type std::stringstream
2013-10-30 12:02 [Bug c++/58924] New: Non-member invocation of overload of operator<< when the first argument is a temporary of type std::stringstream sir_nawaz959 at yahoo dot com
2013-10-30 13:09 ` [Bug c++/58924] " fanael4 at gmail dot com
2013-10-30 13:37 ` daniel.kruegler at googlemail dot com
@ 2013-10-30 13:48 ` redi at gcc dot gnu.org
2013-10-30 13:55 ` sir_nawaz959 at yahoo dot com
3 siblings, 0 replies; 5+ messages in thread
From: redi at gcc dot gnu.org @ 2013-10-30 13:48 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58924
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Component|c++ |libstdc++
Resolution|--- |INVALID
--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> ---
This is not a bug.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug libstdc++/58924] Non-member invocation of overload of operator<< when the first argument is a temporary of type std::stringstream
2013-10-30 12:02 [Bug c++/58924] New: Non-member invocation of overload of operator<< when the first argument is a temporary of type std::stringstream sir_nawaz959 at yahoo dot com
` (2 preceding siblings ...)
2013-10-30 13:48 ` [Bug libstdc++/58924] " redi at gcc dot gnu.org
@ 2013-10-30 13:55 ` sir_nawaz959 at yahoo dot com
3 siblings, 0 replies; 5+ messages in thread
From: sir_nawaz959 at yahoo dot com @ 2013-10-30 13:55 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58924
--- Comment #5 from Sarfaraz Nawaz <sir_nawaz959 at yahoo dot com> ---
(In reply to Fanael from comment #1)
> That's expected behavior AFAIU. 'operator<<(basic_ostream<charT, traits>&&
> os, const T& x)' is a better match for const char[K] than
> 'basic_ostream<charT,traits>& basic_ostream<charT,traits>::operator<<(const
> void* p)', hence the former gets called, which then forwards the arguments
> to 'operator<<(basic_ostream<charT, traits>&& os, const charT* x)'.
Oh. I didn't come across this overload. Great that they've added this.
Invalid bug.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2013-10-30 13:55 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-10-30 12:02 [Bug c++/58924] New: Non-member invocation of overload of operator<< when the first argument is a temporary of type std::stringstream sir_nawaz959 at yahoo dot com
2013-10-30 13:09 ` [Bug c++/58924] " fanael4 at gmail dot com
2013-10-30 13:37 ` daniel.kruegler at googlemail dot com
2013-10-30 13:48 ` [Bug libstdc++/58924] " redi at gcc dot gnu.org
2013-10-30 13:55 ` sir_nawaz959 at yahoo dot com
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).