Path: utzoo!attcan!uunet!husc6!bloom-beacon!mit-eddie!bbn!spdcc!ima!think!barmar
From: barmar@think.COM (Barry Margolin)
Newsgroups: comp.lang.c
Subject: Re: Any bounds-checking C compilers?
Message-ID: <22580@think.UUCP>
Date: 24 Jun 88 15:54:27 GMT
References: <4033@pasteur.Berkeley.Edu>
Sender: usenet@think.UUCP
Reply-To: barmar@kulla.think.com.UUCP (Barry Margolin)
Organization: Thinking Machines Corporation, Cambridge, MA
Lines: 24

In article <4033@pasteur.Berkeley.Edu> faustus@ic.Berkeley.EDU (Wayne A. Christopher) writes:
>Are there any C compilers that compile in run-time bounds checking for array
>accesses?

The Symbolics C compiler, for Symbolics Lisp Machines, does various
kinds of bounds checking.  For malloc'ed data, it makes sure that you
don't reference outside the size you specified; i.e.

	ptr = malloc (10);
	foo = *(ptr + 11)

should generate an error.  For automatic variables, it checks that you
reference within the stack frame, but it doesn't check individual
arrays.

This bounds checking incurs little performance overhead, because it is
done by hardware array instructions, which do the checking in parallel
with the memory reference.

Barry Margolin
Thinking Machines Corp.

barmar@think.com
{uunet,harvard}!think!barmar