From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31502 invoked by alias); 19 Mar 2004 14:57:43 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 31493 invoked by uid 48); 19 Mar 2004 14:57:43 -0000 Date: Fri, 19 Mar 2004 14:57:00 -0000 From: "dvandenbroeck at free dot fr" To: gcc-bugs@gcc.gnu.org Message-ID: <20040319145739.14651.dvandenbroeck@free.fr> Reply-To: gcc-bugzilla@gcc.gnu.org Subject: [Bug c++/14651] New: Segfault while using stringstream X-Bugzilla-Reason: CC X-SW-Source: 2004-03/txt/msg02337.txt.bz2 List-Id: Hello everyone ... - Here is the bug: Using a stringstream on a Sparc Solaris 2 makes the program crash with a Segmentation Fault. However, the problem seems to occur only with g++ 3.x or the libstdc++.5.x. This works well with gcc 2.95.3 and/or libstdc++.so.2.10.0, and on a PC host running GNU/Linux-gcc3.2-libstdc++.so.5 . - Here is the piece of code: testnul.cpp: #include #include using namespace std; int main (void) { string s; stringstream t; t << "Hello"; t >> s; cout << s << endl; return 0; } - Let's try: $ uname -a SunOS myname 5.8 Generic_108528-13 sun4u sparc SUNW,Ultra-4 $ g++ --version g++ (GCC) 3.1 $ g++ testnul.cpp -o testnul $ ldd testnul libstdc++.so.5 => /usr/local/lib/libstdc++.so.5 libm.so.1 => /usr/lib/libm.so.1 libgcc_s.so.1 => /usr/local/lib/libgcc_s.so.1 libc.so.1 => /usr/lib/libc.so.1 libdl.so.1 => /usr/lib/libdl.so.1 /usr/platform/SUNW,Ultra-4/lib/libc_psr.so.1 $ ./testnul Segmentation Fault - I also get a segfault if I disable the string insertion: testnul.cpp: #include #include using namespace std; int main (void) { string s; stringstream t; t << "Hello"; // t >> s; cout << "That's all folks" << endl; return 0; } $ g++ testnul.cpp -o testnul $ ./testnul That's all folks Segmentation Fault - This time, the object seems to crash at destruction time. - Finally, the program stops crashing if I also comment the string declaration. However, it won't crash neither if I don't use a stringstream at all and fill the string with "cin >> s". - I thought it could comes from this bug: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=6784 , so I recompiled the libstdc++ from the latest GCC release (3.3.3) and built the libstdc++.so.5.0.5, but it didn't help. I couldn't rebuild the whole compiler because of a slight lack of space to perform a complete GCC bootstrap. Thanks you in advance ! -- Summary: Segfault while using stringstream Product: gcc Version: 3.1 Status: UNCONFIRMED Severity: normal Priority: P2 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: dvandenbroeck at free dot fr CC: gcc-bugs at gcc dot gnu dot org GCC build triplet: sparc-solaris2 GCC host triplet: sparc-solaris2 GCC target triplet: sparc-solaris2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14651