From: "John M. Aldrich" Newsgroups: comp.os.msdos.djgpp Subject: Re: Symify output is silly ... help please! Thanks! Date: Tue, 12 May 1998 21:25:00 -0400 Organization: Two pounds of chaos and a pinch of salt. Lines: 56 Message-ID: <3558F66C.1758@cs.com> References: <355d83e4 DOT 118624547 AT news DOT fast-net DOT de> <3557F72E DOT BF3BFEE7 AT LSTM DOT Ruhr-UNI-Bochum DOT De> <355e9eb3 DOT 191033954 AT news DOT fast-net DOT de> <3558A2AB DOT 5131 AT erols DOT com> <3558bc5f DOT 198631708 AT news DOT fast-net DOT de> NNTP-Posting-Host: ppp136.cs.net 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 ^Hawk^ wrote: > > On Tue, 12 May 1998 15:27:39 -0400, "John S. Fine" > wrote: > > >at the end of a routine to restore registers and exit. For a > >crash that occurs in that code, what better line number would > >you like the compiler to have chosen than the line number of the > >closing brace. > Where the allocation fault was !? It's not possible for the compiler to do that in any reasonable fashion. C is very lenient; it lets you do almost anything on the assumption that you meant to do it that way. There are some utilities out there that allow you to track memory allocation and there are even some that support runtime array bounds checking. However, the compiler _can_ catch a great number of potential mistakes if you let it. The '-Wall' and '-O' switches, when used in combination, can detect variables that are potentially used without being initialized (among other things). Example code: /* uninit.c */ #include int main( void ) { char *p; gets( p ); return 0; } When compiled with "gcc -Wall -O -g -o uninit.exe uninit.c", the following warning occurs: uninit.c: In function `main': uninit.c:6: warning: `p' might be used uninitialized in this function The problem is that too many people don't know about those incredibly useful warning options. If your problem was not allocating the correct _amount_ of memory for a pointer, then there's no way or reason for the compiler to know that you did anything wrong. -- John M. Aldrich - ICQ UIN# 7406319 * 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