From: "John M. Aldrich" Newsgroups: comp.os.msdos.djgpp Subject: Re: FOUND DJP BUG. Date: Tue, 15 Apr 1997 07:05:59 -0700 Organization: Two pounds of chaos and a pinch of salt Lines: 56 Message-ID: <33538B47.7DA3@NO.SPAM.cs.com> References: <3353E3F7 DOT 6369 AT tc DOT umn DOT edu> NNTP-Posting-Host: ppp108.cs.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk Jawed Karim wrote: > > /* > compile the following code with DJGPP and run it. Observe the output. > Then, run DJP on the executable and run it again. The output differs! I > think that qualifies as a bug, because compressed EXE's should not > behave any differently than uncompressed EXE's. > */ No, this is quite simply a major bug in your program. Allow me to explain, but first let me ask you where in the nine hells you learned C? And who taught you to be so "polite"? Oh, well... here goes: > #include > > void main(void) This is a nono. main() must return an integer value to the operating system - this forms the return code of the program! Don't leave it out, despite what many C books tell you. They are WRONG. > { > char *string = NULL; > > if (*string != NULL) This will never work as intended, because you're dereferencing 'string' before comparing it to NULL. Try just "if ( string != NULL )" here. This should have caused a segmentation violation when you ran the program, unless you tried it under Windows. In DOS, all you'd get is a crash. > printf("\n%s\n", string); > } BTW, the reason for the different behavior with djp is that the data at the virtual address '0x0' is probably part of the program's executable code, or some internal structure of the program, and thus differs when the executable itself is different. I'm surprised that this program worked at all, and didn't cause all sorts of nasty crashes. -- John M. Aldrich * Anything that happens, happens. * Anything that, in happening, causes something else to happen, causes something else to happen. * Anything that, in happening, causes itself to happen again, happens again. * It doesn't necessarily do it in chronological order, though. --- Douglas Adams