Path: utzoo!attcan!uunet!husc6!mailrus!cornell!uw-beaver!tikal!sigma!uw-nsr!john From: john@uw-nsr.UUCP (John Sambrook) Newsgroups: comp.lang.c Subject: Re: Run-time Checks for C Message-ID: <1425@uw-nsr.UUCP> Date: 22 Nov 88 05:19:02 GMT References: <10113@umn-cs.CS.UMN.EDU> Reply-To: john@uw-nsr.UUCP (John Sambrook 548-4386) Organization: UW-Bioengineering, Seattle, WA Lines: 40 In article <10113@umn-cs.CS.UMN.EDU> raghavan@umn-cs.cs.umn.edu (Vijay Raghavan) writes: > > I made a casual statement in a local bulletin board to the effect that >the C language definition doesn't really preclude any implementation from >doing certain run-time checks (for array bounds, type checking, referring >contents of uninitialized pointer variables &c), it's just that most >(okay, all!) implementations don't do any such checking because of efficiency >reasons. Now I'm not sure that this statement is really true (I mean I'm not >sure that sufficient information can always be passed to the compiler for it >to generate code for meaningful run-time checks.) Please note that I have no relationship with Data General Corporation. I just happen to think they have done a good job on their language systems products. The Data General C compiler is an example of a compiler that provides a number of facilities for debugging programs, including several run time checks. All such options are invoked with -C. Two useful switches are -Clineid and -Cprocid. They cause the compiler to include source file line and procedure name information into the generated code. If the program aborts a (stack) traceback is produced that includes this information. Very useful. -Csubcheck causes subscript range checking to be enabled. At run time attempts to reference outside of an array are detected and the program aborts (with a traceback). When possible the compiler detects these errors at compile time. -Cpointercheck is useful for catching uses of improperly typed pointers. While not a fully general mechanism it does catch the types of errors that cause programs to abort on MV series machines. Finally, -Czeroframe causes the compiler to generate code to zero all local variables when a new activation record (stack frame) is created. This has been useful from time to time to track down uses of uninitialized variables. -- John Sambrook Internet: john@nsr.bioeng.washington.edu University of Washington RC-05 UUCP: uw-nsr!john Seattle, Washington 98195 Dial: (206) 548-4386