Mercurial > projects > ldc
comparison 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 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
53:06ccc817acd4 | 54:28e99b04a132 |
---|---|
1 module bug33; | |
2 | |
3 extern(C) int memcmp(void*,void*,size_t); | |
4 | |
5 private int string_cmp(char[] s1, char[] s2) | |
6 { | |
7 auto len = s1.length; | |
8 if (s2.length < len) | |
9 len = s2.length; | |
10 int result = memcmp(s1.ptr, s2.ptr, len); | |
11 if (result == 0) | |
12 result = cast(int)(cast(ptrdiff_t)s1.length - cast(ptrdiff_t)s2.length); | |
13 return result; | |
14 } | |
15 | |
16 struct S | |
17 { | |
18 char[] toString() | |
19 { | |
20 return "S"; | |
21 } | |
22 } | |
23 | |
24 int func() | |
25 { | |
26 S a,b; | |
27 return string_cmp(a.toString(),b.toString()); | |
28 } | |
29 | |
30 void main() | |
31 { | |
32 assert(func() == 0); | |
33 } |