This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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?


IIRC, in java an object can only have 2^16 fields, so if the maximum field size is 8 bytes (a reference), That means you only have to keep the first 2^19 bytes unmapped. For arrays, we would generally have to examine the 'length' field before any other access, and it would be near the beginning also.

I think that in practice the os/runtime linker will leave a piece of the address space much larger than 2^19 unmapped.


David Daney



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]