Bug 31539

Summary: casting of Foo foo works, casting of Foo() does not
Product: [Retired] Red Hat Linux Reporter: stano
Component: gccAssignee: Jakub Jelinek <jakub>
Status: CLOSED DEFERRED QA Contact: David Lawrence <dkl>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.0   
Target Milestone: ---   
Target Release: ---   
Hardware: i386   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2001-03-12 18:48:39 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description stano 2001-03-12 18:48:35 UTC
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 18:12:59 UTC
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.