Path: utzoo!utgpu!water!watmath!clyde!rutgers!ukma!husc6!hao!noao!mcdsun!sunburn!gtx!al From: al@gtx.com (0732) Newsgroups: comp.lang.c Subject: Re: Possible extension to C?? Message-ID: <525@gtx.com> Date: 11 Jan 88 20:58:57 GMT References: <3306@ihlpf.ATT.COM> Reply-To: al@gtx.UUCP (Al Filipski 839-0732) Organization: GTX Corporation, Phoenix Lines: 35 In article <3306@ihlpf.ATT.COM> nevin1@ihlpf.UUCP (00704A-Liber,N.) writes: >I have a proposal for a extension to C WHICH DOES NOT BREAK EXISTING CODE. > >I feel that *0 should be equal to 0 (at least for the data types char, short, >int, long and 'pointer'). > [I assume you really mean *x where x is a NULL pointer] Run-time checking is contrary to the spirit and original design goals of C (which were, if I recall some of the early scripture correctly, that it be [1] not assembly language and [2] as fast as possible.) However, I think it would be great if more compilers offered a switch to turn on as much run-time checking as possible. Besides the null pointer deref, one heuristic for catching some bad references would be to look for (syntactic) occurrences of x[] where x is the name of an array and insert code to check whether exceeds the dimensioned bound. This would help the re-tread Fortran programmers who write in the traditional array[subscript] style, but would not help REAL C programmers who write *(x + ) or those who contrariwise prefer ()[x] or those who just use pointers (not arrays) for everything. It would just be a heuristic whose usefulness depends on your programming style. Doen anyone make a "run-time lint" compiler (short of an interpreter) to put in checks for things like this? ---------------------------------------------------------------------- | Alan Filipski, GTX Corp, 2501 W. Dunlap, Phoenix, Arizona 85021, USA | | {ihnp4,cbosgd,decvax,hplabs,seismo}!sun!sunburn!gtx!al (602)870-1696 | ----------------------------------------------------------------------