Pointer to string allows assigning int[]?

Andrej Mitrovic andrej.mitrovich at gmail.com
Mon Nov 12 13:11:22 PST 2012


On 11/12/12, cal <callumenator at gmail.com> wrote:
> Is the following a bug?

Reduced:

void main()
{
    string x = "foo";
    string* y = &x;
    *y = [1, 2, 3];
    assert(x == "foo"); // fails
}

Yes this is a bug, especially since the string is typed as immutable(char)[].


More information about the Digitalmars-d-learn mailing list