On Thu, Mar 16, 2006 at 06:47:39AM -0800, Yann POUPET wrote:
> Hello,
> 
> I was wondering if it is a "normal" behaviour to segfault when
> puts(3C) receives a NULL pointer ?

puts() receiving a NULL pointer is a bug.  The standards don't specify
what happens in this case (the behavior is "undefined"), and Solaris
chose to do the safest thing;  dump a core so that someone can track down
the problem.

> I mean, couldn't puts() check for its arg and do something "smart" if
> it is NULL ?

Well, it *could*, but that would (very slightly) slow down a common routine,
and wouldn't help if someone passed (say) (char *)1 or some other invalid
pointer.  It's much more sensible just to crash.

Cheers,
- jonathan

-- 
Jonathan Adams, Solaris Kernel Development
_______________________________________________
opensolaris-code mailing list
[email protected]
http://mail.opensolaris.org/mailman/listinfo/opensolaris-code

Reply via email to