Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!munnari.oz.au!brolga!bunyip.cc.uq.oz.au!zeus!s64421 From: s64421@zeus.usq.EDU.AU (house ron) Newsgroups: comp.lang.c Subject: An Ubiquitous C bug Message-ID: Date: 21 Jan 91 15:22:12 GMT Lines: 30 Here's a bug which exists in every single DOS C compiler I can find, and may also exist on others: In the small memory model, it is possible for a function to have the address NULL. E.G.: void x() { ... } main() { void (*y)(); y = x; if (y==NULL) printf ("AARRGGHH!!\n"); } This sort of program CAN print the message if x() happens to be loaded by the linker at the start of the code segment (address 0). The compiler seems unable to prevent the linker from loading functions at that address. Perhaps on some machines, NULL should _not_ be 0? After all, it would be easy to prevent functions being loaded at address 1 (for example) on a DOS machine. -- Regards, Ron House. (s64421@zeus.usq.edu.au) (By post: Info Tech, U.C.S.Q. Toowoomba. Australia. 4350)