view test/bug33.d @ 54:28e99b04a132 trunk

[svn r58] Fixed cond expression resulting in a non-basic type. Fixed identity expression for dynamic arrays. Revamped the system to keep track of lvalues and rvalues and their relations. Typedef declaration now generate the custom typeinfo. Other bugfixes.
author lindquist
date Wed, 24 Oct 2007 01:37:34 +0200
line wrap: on
line source
module bug33;

extern(C) int memcmp(void*,void*,size_t);

private int string_cmp(char[] s1, char[] s2)
    auto len = s1.length;
    if (s2.length < len)
        len = s2.length;
    int result = memcmp(s1.ptr, s2.ptr, len);
    if (result == 0)
        result = cast(int)(cast(ptrdiff_t)s1.length - cast(ptrdiff_t)s2.length);
    return result;

struct S
    char[] toString()
        return "S";

int func()
    S a,b;
    return string_cmp(a.toString(),b.toString());

void main()
    assert(func() == 0);