On Wed, 13 Jul 2011 13:32:56 -0400, Regan Heath <[email protected]> wrote:

On Wed, 13 Jul 2011 17:00:39 +0100, Steven Schveighoffer <[email protected]> wrote:

How does your proposal know that a char * is part of a heap-allocated array? If you are assuming the only case where char * is passed will be arr.ptr, then that doesn't cut it. What if the compiler doesn't know where the char * came from?

See your Q and my A above ("char * foo" example).

The inherent problem of zero-terminated strings is that you don't know how long it is until you search for a zero. If it's not properly terminated, then you are screwed. That problem cannot be "solved", even with compiler help -- you can get situations where there is no more information other than the pointer.

Really? But cant we obtain the GC lock and look them up, as mentioned above? And isn't this exactly what toStringz will do when the programmer first of all curses because it has crashed, and then adds an explicit toStringz call?

Who said the char * points into GC memory? It could point at stack memory, or static data in ROM.

-Steve

Reply via email to