> From: David Daney > Sent: Tuesday, November 15, 2005 11:44 AM > To: Mike Stump > Cc: gcc@gcc.gnu.org; [EMAIL PROTECTED] > Subject: Re: Null pointer check elimination > > > Mike Stump wrote: > > On Nov 14, 2005, at 11:36 PM, David Daney wrote: > > > >> Perhaps not in general, but one unstated premise of this whole > >> thread > >> is that for some GCC targets (most Unix like operating > systems) you > >> *can* count on a SIGSEGV when you dereference a null pointer. > > > > > > Unless that null pointer points to an object that is of the wrong > > size > > (too large), such as an array or a structure. > > The java front end ignores this case. I mean what are the > chances that > someone would try to access something near the end of such an object > with out first trying to access something near the beginning of it? If the code is malicious, probably about 100%.
It seems to me that we probably do want a solid guarantee here eventually. As David wrote later, we probably already have one on most platforms. The libjava GC code also currently makes some weaker assumptions along these lines. It believes that none of the GC heap resides at addresses below 16K (see _Jv_AllocArray in boehm.cc). But that's more of a performance than correctness issue. Hans