This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
cerr and NULL terminates program + string::find() weird results
- From: Anibal Jodorcovsky <anibal at intelerad dot com>
- To: libstdc++ at gcc dot gnu dot org
- Cc: neelin at intelerad dot com, Kent Tse <kent at intelerad dot com>
- Date: Sat, 12 Oct 2002 12:26:30 -0400
- Subject: cerr and NULL terminates program + string::find() weird results
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