Bug 31539 - casting of Foo foo works, casting of Foo() does not
casting of Foo foo works, casting of Foo() does not
Status: CLOSED DEFERRED
Product: Red Hat Linux
Classification: Retired
Component: gcc (Show other bugs)
7.0
i386 Linux
medium Severity medium
: ---
: ---
Assigned To: Jakub Jelinek
David Lawrence
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2001-03-12 13:48 EST by stano
Modified: 2007-04-18 12:32 EDT (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2001-03-12 13:48:39 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description stano 2001-03-12 13:48:35 EST
From Bugzilla Helper:
User-Agent: Mozilla/4.76 [en] (X11; U; Linux 2.4.0 i686)


The following short sample of C++ code does not compile (see Steps to
Reproduce)

Reproducible: Always
Steps to Reproduce:
Try to compile following code sample by g++:

=== snip ===
#include <sstream>
#include <string>

void foo(const std::ostringstream &testStream)
{
}

main()
{
        std::ostringstream testStream;
        std::string testString;

        foo((static_cast<std::ostringstream &>
                (testStream << testString)));
        foo((static_cast<std::ostringstream &>
                (std::ostringstream() << testString)));
}
=== snip ===

Actual Results:
g++ cast.cc
cast.cc: In method `ostream::ostream (const ostream &)':
/usr/include/g++-3/streambuf.h:128: `ios::ios (const ios &)' is private
cast.cc:16: within this context
cast.cc: In function `int main ()':
cast.cc:16: could not convert `ostream(1, ((&ostringstream(1, 2)) + 
176))' to `ostream &'
/usr/include/g++-3/std/bastring.h:654: in passing argument 1 of 
`operator<< (ostream &, const basic_string<charT, traits, Allocator> &) 
[with charT = char, traits = string_char_traits<char>, Allocator = 
__default_alloc_template<true, 0>]'


Expected Results:  Either cleanly compiled code, or (in the event the code
is not correct) error messages regarding _both_ foo() calls, not only one.

gcc version 2.96 20000731 (Red Hat Linux 7.0)
gcc-2.96-69
gcc-c++-2.96-69
libstdc++-2.96-69
libstdc++-devel-2.96-69
Comment 1 Jakub Jelinek 2001-04-05 14:12:59 EDT
sstream in gcc-2.96-RH is young (was not present at all in 2.95.x) and
has issues like this. As it works properly in libstdc++-v3 (on gcc-3_0-branch)
where it is completely rewritten and as fixing this would require rewriting
*stringstream support once again, I'm deferring this; it will be fixed as soon
as gcc-3.0 makes it into the distribution.

Note You need to log in before you can comment on or make changes to this bug.