<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
<br>
<br>
Michel Fortin wrote:
<blockquote cite="mid:A96C525A-A2C7-4994-9C37-8B3C09E2E18B@michelf.com"
type="cite">
<pre wrap="">Le 2010-08-22 à 17:07, Walter Bright a écrit :
</pre>
<blockquote type="cite">
<pre wrap="">Sean Kelly wrote:
</pre>
<blockquote type="cite">
<pre wrap="">I think it depends on how the compiler dereferences fields of an object. GCC on OSX if I have a null ptr to a struct and I try to access a field through it I'll get the data at 0x4 or wherever and the code will keep on running. Actual segfaults happen depressingly rarely.
</pre>
</blockquote>
<pre wrap="">On Windows, the entire first 64K of address space is reserved by the OS, and any attempt to access it results in a seg fault. I'm very surprised that OS X would not do the same.
</pre>
</blockquote>
<pre wrap=""><!---->
A quick test with DMD on OS X reveals that reading anything below the first 4K of the address space causes a segfault.
For instance, reading member b of a null pointer to this struct will not cause a segfault:
        struct S {
                ubyte[4*1024] a;
                ubyte b;
        }
        S* s = null;
        ubyte c;
        @safe void main() {
                c = s.b;
        }
Remove one byte from array a and you have a segfault.
</pre>
</blockquote>
<br>
That's a lot better than just 4 bytes, but it's still mysterious why
they don't do the full 64K.<br>
</body>
</html>