This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: cerr and NULL terminates program + string::find() weird results
On Wed, Oct 16, 2002 at 05:43:06PM -0400, Anibal Jodorcovsky wrote:
> well, how about (null)
"(null)" could just as easily come from a user library, or user code. We
do not want to make assumptions about what a user wants when performing
undefined behavior. What one user likes, another use doesn't.
> and dumping core. At least we know why and then it's
> easier to find the problem?
Why would it dump core? It's not crashing.
#include <iostream>
int main()
{
const char* const d = 0;
std::cerr << d << std::endl;
if (std::cerr.good())
std::cout << "cerr's state is okay\n";
else
std::cout << "cerr's state is bad, something bad "
<< "has been sent to cerr\n";
std::cerr << "not printing this, because cerr is disabled" << std::endl;
std::cerr.clear();
std::cerr << "cerr is back to normal now\n";
}
Try running that.
Phil
--
I would therefore like to posit that computing's central challenge, viz. "How
not to make a mess of it," has /not/ been met.
- Edsger Dijkstra, 1930-2002