Bus error accessing char [] by index - OS X

Regan Heath regan at netmail.co.nz
Wed Nov 7 02:26:21 PST 2007


Regan Heath wrote:
> Cam MacRae wrote:
>> BCS Wrote:
>>
>>> Reply to Cam,
>>>
>>>
>>> On linux, string literals are in read only memory space. As for OS
>>> X...???
>>>
>>>
>>
>> Thanks mate - that could be it. I was just following along the D
>> Transition guide (http://en.wikibooks.org/wiki/D_Transition_Guide).
>> Perhaps it's out of date...
> 
> More like "windows centric" as string literals can be written to on 
> windows.
> 
> Simple fix:
> 
>         char[] a = firstname.dup, b = firstname;
>         a[0] = 'H'; //5

Actually, this breaks the example entirely as b is no longer modified by 
a[0] - 'H' oops.

Regan



More information about the Digitalmars-d mailing list