This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug middle-end/40391] Segfault with -O, iostream, anonymous namespace on PPC



------- Comment #6 from fp at mc dot com  2009-06-10 12:50 -------
Jonathan,

thank you for identifying the bug in my original code.

According to my copy of ISO 14992:1998, std::iostream does not have a default
constructor.  However, my reading of the standard leads me to believe that it
is valid to pass a null pointer.  The description for basic_ios::init()
(27.4.4.1) says that, as a postcondition, rdstate() is "goodbit if sb is not a
null pointer, otherwise badbit".

libstdc++ does provide a default constructor for std::iostream.

However, either way, passing a null std::streambuf pointer to std::iostream
(which I believe is valid), or calling the "gcc extension" default constructor,
both still lead to a crash.

I've looked at the source code for std::iostream and its base classes and it
does not appear to dereference sb, it merely assigns the pointer to a meber
variable and tests it for non-null.

I am updating the test case.

Can someone please do me a favor and test this with a more current version of
gcc?


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40391


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]