From mboxrd@z Thu Jan 1 00:00:00 1970 From: Alexandre Oliva To: "Puneet Singhal" Cc: "Gcchelp" Subject: Re: Coredump Date: Thu, 14 Dec 2000 08:12:00 -0000 Message-id: References: X-SW-Source: 2000-12/msg00076.html On Dec 14, 2000, "Puneet Singhal" wrote: > The same code works fine on NCR UNIX It works fine on all systems. It's just a matter of defining `fine'. The code invokes undefined behavior, so the run-time library is entitled to do anything at all. It might have formatted your hard disk as well :-) > When we port the same code to Solaris Sparc it gives a core dump why?? Because printf() ends up dereferencing the NULL pointer you passed to it. It might have checked whether the given pointer was NULL, but then every single printf() of a string would incur this cost. Why impose this cost upon everybody, given that NULL isn't a valid string anyway? Besides, by having the program crash at that point, you can easily figure out where the problem is from the stack trace you can get from the core file, and fix it. If printf just printed some odd string, you'd have far more trouble figuring out which statement in your program makes the invalid printf call. -- Alexandre Oliva Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/ Red Hat GCC Developer aoliva@{cygnus.com, redhat.com} CS PhD student at IC-Unicamp oliva@{lsd.ic.unicamp.br, gnu.org} Free Software Evangelist *Please* write to mailing lists, not to me