Steven Schveighoffer wrote:
On Mon, 22 Feb 2010 09:27:57 -0500, strtr <st...@spam.com> wrote:
Thanks, I understand.
But, how about a runtime error?
Isn't a literal placed in easy to identify should-only-read memory?

A segfault is a runtime error. The problem with Windows is it doesn't throw an error on writes to its data segment (unlike Linux). In reality, the result of your program is undefined, so don't expect any help from the compiler/runtime. There's nothing D1 can do about that. In order for D to intercept that, it would have to instrument every write to memory, and that would cause performance problems like you wouldn't believe.

Windows can protect memory as read-only too. Why dmd doesn't do that is a mystery. Even if .exe doesn't support read-only data segments, the runtime could have done so in early start-up code.

The short answer: Just don't do that.

-Steve

Reply via email to