Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!husc6!rutgers!rochester!PT!cadre!pitt!darth!apex!gary From: gary@apex.UUCP (Gary Wisniewski) Newsgroups: comp.lang.c Subject: Re: Passing (char *) NULL to printf to match %s Message-ID: <298@apex.UUCP> Date: Fri, 14-Aug-87 20:16:25 EDT Article-I.D.: apex.298 Posted: Fri Aug 14 20:16:25 1987 Date-Received: Tue, 18-Aug-87 06:18:38 EDT References: <166@qetzal.UUCP> <157@hobbes.UUCP> <875@bsu-cs.UUCP> <1219@cognos.UUCP> <25173@sun.uucp> Reply-To: gary@apex.UUCP (Gary Wisniewski) Organization: Apex Software Corp., Pittsburgh, Pa. Lines: 32 Keywords: MSC,NULL Summary: NULL is ds:0, why would anyone put strings there? In article <25173@sun.uucp> guy%gorodish@Sun.COM (Guy Harris) writes: >> Speaking of this... has anyone else noticed any problems with this in >> small model Microsoft C? I seem to be unable to print out a string that >> happens to be placed at offset 0 of the data segment -- MSC's libraries >> decide it is a null pointer and format it as "(null)". > [ ... comments about NULLness of pointers ... ] >Either Microsoft C allowed it to be placed there [ds:0], in which case >*that* is the bug, or somebody got around whatever mechanism ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >Microsoft C provides to ensure that no C object gets put at that >location, in which case they got what they deserved. > Guy Harris Code at the beginning of DS is an unlikely place to find user strings. Microsoft places a small unchanging bit of junk there which it keeps a checksum on. If that section is written to during program execution, MSC prints out "Error 2000: Null Pointer Assignment" when the program terminates (the message may not be quite right---you get the idea). This is actually a helpful technique in lieu of hardware address fault checking. It is also nice that NULL pointer references don't destroy anything of great importance. The original sender (name not known) seems to have reorganized or rewritten the stock MSC runtime library routines. I can't think of any other way to get useful code at DS:0. However, the tone of their comments suggests that the NULL behavior is a mystery to them (anyone who had rewritten runtime libraries would doubtless understand the formalities of segment usage under MSC!)---Hmmmm. Gary Wisniewski {allegra,bellcore,cadre}!pitt!darth!apex!gary