--- In GPCP@yahoogroups.com, "Marc Martin" <marc@...> wrote:
>
> Yes, in the original code, this was part of an initialization sequence.
> The debugger claims that the crash happens with the assignment, not
> with an access.
>
> But certainly using str := ""; works for initialization purposes as well...
>
Sorry, my mistake, I misread your original message. Your question makes a lot
more sense to me now! You are right - it shouldn't crash when you assign:
str := NIL;
As System.String is a POINTER TO A RECORD.
However, in practice it looks like the problem is related to the way GPCP
attempts to provide convenient automatic interchangeability between .NET's
System.String and CP's ARRAY OF CHAR.
If you look at the IL code generated for this statement:
.line 8,8:6,9 'NullString.cp'
ldnull
call string [RTS]CP_rts::mkStr(wchar[])
stsfld string NullString.NullString::'str'
You can see that it is effectively making a call to MKSTR behind the scenes. I
presume that passing a null value to the mkStr function is what is generating
the exception.
Regards,
Chris