cerr and NULL terminates program + string::find() weird results

Anibal Jodorcovsky anibal@intelerad.com
Sat Oct 12 09:26:00 GMT 2002


Hi there,

I'm using g++ 3.1.1 and the STL that came with it (libstdc++.so.4.0.1) under
redhat 6.2.

I have one weird thing happening. Look at the following code:

#include <iostream>
int
  main()
{
    const char* const c1 = "C1";
    const char* const c2 = "C2";
    const char* const d  = NULL;
    const char* const c3 = "C3";

    std::cerr << "c1 is " << c1 << std::endl;
    std::cerr << "c2 is " << c2 << std::endl;
    std::cerr << "d  is " << d << std::endl;
    std::cerr << "c3 is " << c3 << std::endl;
    return 0;
}

the output is:

c1 is C1
c2 is C2
d  is [root@anibal /tmp]#

So, as you see the program misteriously terminates when trying to cerr a
NULL const char*.

Any pointers will be greatly appreciated,

-Anibal




More information about the Libstdc++ mailing list