1 /*
2 REQUIRED_ARGS:
3 TEST_OUTPUT:
4 ---
5 success
6 myInt int
7 myBool bool
8 i
9 s
10 C6test42__T4T219TiZ1C
11 C6test427test219FZ8__mixin11C
12 ---
13 */
14 
15 module test42;
16 
17 import core.stdc.stdio;
18 import core.memory;
19 import core.vararg;
20 
21 /***************************************************/
22 
23 class Foo {
24     template myCast(T) {
25         T myCast(U)(U val) {
26             return cast(T) val;
27         }
28     }
29 }
30 
31 void test1()
32 {
33   Foo foo = new Foo;
34   int i = foo.myCast!(int)(1.0);
35 }
36 
37 /***************************************************/
38 
39 template A()
40 {
41   static T foo(T)(T t) { return 7 + t; }
42 }
43 
44 struct Bar
45 {
46   mixin A!() a;
47 }
48 
49 void test2()
50 {
51   auto i = A!().foo(1);
52   assert(i == 8);
53   i = Bar.a.foo!(int)(2);
54   assert(i == 9);
55   i = Bar.a.foo(3);
56   assert(i == 10);
57 }
58 
59 /***************************************************/
60 
61 void test3()
62 {
63     auto i = mixin("__LINE__");
64     printf("%d\n", i);
65     assert(i == 63);
66 }
67 
68 /***************************************************/
69 
70 class C4
71 {
72     void Stamp(){}
73 
74     this() { }
75 
76     S4 cursor;
77 }
78 
79 struct S4
80 {
81 }
82 
83 void test4()
84 {
85 }
86 
87 /***************************************************/
88 
89 char a5 = (cast(char[])['a']) [$-1];
90 
91 void test5()
92 {
93     assert(a5 == 'a');
94 }
95 
96 /***************************************************/
97 // https://issues.dlang.org/show_bug.cgi?id=1200
98 // One case moved to deprecate1.d
99 
100 void foo6a() {
101         do
102                 debug {}
103         while (true);
104 }
105 
106 void foo6b() {
107         while (true)
108                 debug {}
109 }
110 
111 void foo6c() {
112         with (Object.init)
113                 debug {}
114 }
115 
116 void foo6d() {
117         synchronized debug {}
118 }
119 
120 void foo6e() {
121 //        volatile debug {}
122 }
123 
124 void test6()
125 {
126 }
127 
128 /***************************************************/
129 
130 class C7 {
131     public this(){
132     }
133 }
134 
135 interface I7 {
136     void fnc();
137 }
138 
139 void test7()
140 {
141     char[][] t;
142     foreach( char[] c; t ){
143         new class( c ) C7, I7 {
144             public this( char[] c ){
145                 super();
146             }
147             void fnc(){
148             }
149         };
150     }
151 }
152 
153 /***************************************************/
154 
155 const ulong[] A8 = ([1LU])[0..$];
156 
157 void test8()
158 {
159     assert(A8[0] == 1);
160 }
161 
162 /***************************************************/
163 
164 void test9()
165 {
166     //writeln(long.max.stringof);
167     //writeln(ulong.max.stringof);
168     assert(long.max.stringof == "9223372036854775807L");
169     assert(ulong.max.stringof == "18446744073709551615LU");
170 }
171 
172 /***************************************************/
173 
174 const ulong[] A10 = [1UL];
175 const ulong[] B10 = A10 ~ [1UL];
176 
177 void test10()
178 {
179 }
180 
181 /***************************************************/
182 
183 class Base11 {
184         private final void foo() {}
185 }
186 
187 class Derived11 : Base11 {
188         void foo() {}
189 }
190 
191 void test11()
192 {
193 }
194 
195 /***************************************************/
196 
197 void test12()
198 {
199     int[] bar;
200     assert((bar ~ 1).length == bar.length + 1);
201 
202     int[][] baz;
203     assert((baz ~ cast(int[])[1]).length == baz.length + 1);
204 
205     char[][] foo;
206     assert((foo ~ cast(char[])"foo").length == foo.length + 1);
207     assert((cast(char[])"foo" ~ foo).length == foo.length + 1);
208 
209     printf("%zd\n", (foo ~ cast(char[])"foo")[0].length);
210 
211     assert((foo ~ [cast(char[])"foo"]).length == foo.length + 1);
212 
213     char[] qux;
214     assert(([qux] ~ cast(char[])"foo").length == [qux].length + 1);
215 
216     assert(([cast(dchar[])"asdf"] ~ cast(dchar[])"foo").length == [cast(dchar[])"asdf"].length + 1);
217 
218     string[] quux;
219     auto quuux = quux.dup;
220     quuux ~= "foo";
221     assert (quuux.length == quux.length + 1);
222 }
223 
224 /***************************************************/
225 
226 int prop() { return 3; }
227 
228 void test13()
229 {
230   auto x = prop;
231   assert(x == 3);
232 }
233 
234 /***************************************************/
235 
236 void recurse(ref int i)
237 {
238     int j = i;
239     recurse(j);
240 }
241 
242 void test14()
243 {
244 }
245 
246 /***************************************************/
247 
248 void bar15(void delegate(int) dg)
249 {
250     dg(7);
251 }
252 
253 class C15
254 {
255     int x;
256 
257     private void callback(int i)
258     {
259         x = i + 3;
260     }
261 
262     void foo()
263     {
264         bar15(&callback);
265         assert(x == 10);
266     }
267 }
268 
269 void test15()
270 {
271     C15 c = new C15();
272 
273     c.foo();
274 }
275 
276 /***************************************************/
277 
278 void bar16(int i, ...) { }
279 
280 void foo16() { }
281 void foo16(int) { }
282 
283 void test16()
284 {
285     bar16(1, cast(void function())&foo16);
286 }
287 
288 /***************************************************/
289 
290 void foo17(char[4] buf, dchar c) { }
291 void foo17(string s) { }
292 void foo17(wstring s) { }
293 
294 
295 void test17()
296 {
297     wstring w;
298     .foo17(w);
299 }
300 
301 /***************************************************/
302 
303 struct S18
304 {
305   version (Dversion2)
306   {
307     static void opCall(string msg) { assert(0); }
308   }
309     static void opCall() { }
310 }
311 
312 void test18()
313 {
314     S18();
315 }
316 
317 /***************************************************/
318 
319 class C19
320 {
321   version (Dversion2)
322   {
323     static void opCall(string msg) { assert(0); }
324   }
325     static void opCall() { }
326 }
327 
328 void test19()
329 {
330     C19();
331 }
332 
333 /***************************************************/
334 
335 extern (System) void test20()
336 {
337 }
338 
339 /***************************************************/
340 
341 void func21()
342 {
343 }
344 
345 int foo21()
346 {
347    return *cast(int*)&func21;
348 }
349 
350 void test21()
351 {
352     foo21();
353 }
354 
355 /***************************************************/
356 
357 void bar22(alias T)()
358 {
359         assert(3 == T);
360 }
361 
362 class Test22
363 {
364         int a;
365         mixin bar22!(a);
366 }
367 
368 void test22()
369 {
370         Test22 t = new Test22();
371         t.a = 3;
372         t.bar22();
373 }
374 
375 /***************************************************/
376 
377 static this()
378 {
379    printf("one\n");
380 }
381 
382 static this()
383 {
384    printf("two\n");
385 }
386 
387 static ~this()
388 {
389    printf("~two\n");
390 }
391 
392 static ~this()
393 {
394    printf("~one\n");
395 }
396 
397 void test23()
398 {
399 }
400 
401 /***************************************************/
402 
403 class Foo24
404 {
405     static string gen()
406     {
407         return "abc";
408     }
409 }
410 
411 auto s24 = Foo24.gen();
412 
413 void test24()
414 {
415     assert(s24 == "abc");
416 }
417 
418 /***************************************************/
419 
420 void test25()
421 {
422     int[10] arrayA = [0,1,2,3,4,5,6,7,8,9];
423     foreach(int i; arrayA)
424     {
425         printf("%d\n", i);
426     }
427 }
428 
429 /************************************/
430 
431 const char[][7] DAY_NAME = [
432         DAY.SUN: "sunday", "monday", "tuesday", "wednesday",
433           "thursday", "friday", "saturday"
434 ];
435 
436 enum DAY { SUN, MON, TUE, WED, THU, FRI, SAT }
437 
438 void test27()
439 {
440     assert(DAY_NAME[DAY.SUN] == "sunday");
441     assert(DAY_NAME[DAY.MON] == "monday");
442     assert(DAY_NAME[DAY.TUE] == "tuesday");
443     assert(DAY_NAME[DAY.WED] == "wednesday");
444     assert(DAY_NAME[DAY.THU] == "thursday");
445     assert(DAY_NAME[DAY.FRI] == "friday");
446     assert(DAY_NAME[DAY.SAT] == "saturday");
447 }
448 
449 /***************************************************/
450 
451 void test28()
452 {
453 }
454 
455 /***************************************************/
456 
457 struct C29 {
458 
459     C29 copy() { return this; }
460 }
461 
462 void foo29(C29 _c) {
463 
464     foo29( _c.copy() );
465 }
466 
467 void test29() {
468 
469     C29 c;
470 
471     //foo(c);
472 }
473 
474 /***************************************************/
475 
476 template Tuple31(T...) { alias T Tuple31; }
477 alias Tuple31!(int,int) TType31;
478 
479 void bar31(TType31) {
480 }
481 
482 void test31()
483 {
484 }
485 
486 /***************************************************/
487 
488 template Foo32(T : S!(T), alias S)
489 {
490     alias int Foo32;
491 }
492 
493 struct Struct32(T)
494 {
495 }
496 
497 void test32()
498 {
499     Foo32!(Struct32!(int)) f;
500 }
501 
502 /***************************************************/
503 
504 void test33()
505 {
506     string a = "a";
507     string b = "b";
508     string c = a ~ b;
509     assert(c == "ab");
510 }
511 
512 /***************************************************/
513 
514 void foo34(in string s)
515 {
516     string t = s;
517 }
518 
519 void test34()
520 {
521 }
522 
523 /***************************************************/
524 
525 struct S35
526 {
527    string toString()
528    {
529        return "foo";
530    }
531 }
532 
533 void test35()
534 {   S35 s;
535     auto t = typeid(S35);
536     //writefln("s = %s", s);
537     //writefln("s = %s", t);
538     auto tis = cast(TypeInfo_Struct)t;
539     //writefln("s = %s", tis);
540     //writefln("s = %s", tis.xtoString);
541     assert(tis.xtoString != null);
542 }
543 
544 /***************************************************/
545 
546 void test36()
547 {
548     void[0] x;
549     auto y = x;
550     alias x z;
551 }
552 
553 /***************************************************/
554 
555 template isStaticArray(T : U[], U)
556 {
557     const bool isStaticArray = is(typeof(U) == typeof(T.init));
558 }
559 
560 template isStaticArray(T, U = void)
561 {
562     const bool isStaticArray = false;
563 }
564 
565 template isStaticArray(T : T[N], size_t N)
566 {
567     const bool isStaticArray = true;
568 }
569 
570 static assert (isStaticArray!(int[51]));
571 static assert (isStaticArray!(int[][2]));
572 static assert (isStaticArray!(char[][int][11]));
573 static assert (!isStaticArray!(int[]));
574 static assert (!isStaticArray!(int[char]));
575 static assert (!isStaticArray!(int[1][]));
576 
577 static assert(isStaticArray!(void[0]));
578 
579 void test37()
580 {
581 }
582 
583 /***************************************************/
584 
585 template Foo38(T)
586 {
587     const bool Foo38 = false;
588 }
589 
590 template Foo38(T : U[N], U, size_t N)
591 {
592     const bool Foo38 = true;
593 }
594 
595 void test38()
596 {
597     static assert (Foo38!(int[51]));
598 }
599 
600 /***************************************************/
601 
602 void test39()
603 {
604 }
605 
606 /***************************************************/
607 
608 void test40()
609 {
610     static x = [[1.0, 2.0], [3.0, 4.0]]; // works
611     assert(x[0][0] == 1.0);
612     assert(x[0][1] == 2.0);
613     assert(x[1][0] == 3.0);
614     assert(x[1][1] == 4.0);
615 
616     auto y = [[1.0, 2.0], [3.0, 4.0]]; // fails
617     assert(y[0][0] == 1.0);
618     assert(y[0][1] == 2.0);
619     assert(y[1][0] == 3.0);
620     assert(y[1][1] == 4.0);
621 }
622 
623 /***************************************************/
624 
625 align(16) struct S41
626 {
627     int[4] a;
628 }
629 
630 shared int x41;
631 shared S41 s41;
632 
633 void test41()
634 {
635     printf("&x = %p\n", &x41);
636     printf("&s = %p\n", &s41);
637     assert((cast(int)&s41 & 0xF) == 0);
638 }
639 
640 /***************************************************/
641 
642 int test42(string[] args = null)
643 {
644    foreach(p; args){
645       version(dummy) int i;
646    }
647    return 0;
648 }
649 
650 
651 /***************************************************/
652 
653 void foo43(float length, byte b)
654 {
655 //    b /= cast(cfloat) length;
656 }
657 
658 void test43()
659 {
660 }
661 
662 /***************************************************/
663 
664 void test44()
665 {
666     ifloat f = 1.0fi;
667 //    f *= 2.0fi; // illegal but compiles
668     printf("%g\n", f);
669 //    assert(f == 0i);
670 }
671 
672 /***************************************************/
673 
674 int foo45(int i)
675 {
676    if(i==0){
677       return 2;
678    }
679    assert(0);
680 }
681 
682 void test45()
683 {
684    version (Win32)  // this test fails in -release because asserts will be removed
685    {
686    assert(foo45(0)==2);
687    try{
688       foo45(1);
689    }catch(Throwable){
690       return cast(void)0;
691    }
692    assert(0);
693    }
694 }
695 
696 /***************************************************/
697 
698 
699 void va_copy46(out void* dest, void* src)
700 {
701     dest = src;
702 }
703 
704 void test46()
705 {
706 }
707 
708 /***************************************************/
709 
710 void test47()
711 {
712     enum { _P_WAIT, _P_NOWAIT, _P_OVERLAY }
713 
714     alias _P_WAIT P_WAIT;
715     alias _P_NOWAIT P_NOWAIT;
716 }
717 
718 /***************************************************/
719 
720 void f48(int x)
721 {
722     const(char)[] blah = (x == 1 ? "hello".dup : "world");
723 }
724 
725 void test48()
726 {
727     f48(1);
728 }
729 
730 /***************************************************/
731 
732 void test49()
733 {
734     assert((25.5).stringof ~ (3.01).stringof == "25.53.01");
735     assert(25.5.stringof ~ 3.01.stringof == "25.53.01");
736 }
737 
738 /***************************************************/
739 
740 class Ap50
741 {
742     ulong size;
743     static uint valuex;
744 
745     void update(ubyte input, int i)
746     {
747         valuex =
748             (((size + i) & 1) == 0) ?
749                     0 :
750                     input;
751     }
752 }
753 
754 void test50()
755 {
756 }
757 
758 /***************************************************/
759 
760 int* foo51()
761 {
762     assert(is(typeof(return) == int*));
763     return null;
764 }
765 
766 void test51()
767 {
768     foo51();
769 }
770 
771 /***************************************************/
772 
773 template Foo52(ulong U)
774 {
775     int Foo52 = 1;
776 }
777 
778 template Foo52(uint U)
779 {
780     int Foo52 = 2;
781 }
782 
783 template Foo52(ubyte U)
784 {
785     int Foo52 = 3;
786 }
787 
788 
789 void test52()
790 {
791     const uint u = 3;
792     auto s = Foo52!(u);
793     assert(s == 2);
794 }
795 
796 /***************************************************/
797 
798 void test53()
799 {
800     extern int x;
801 }
802 
803 /***************************************************/
804 
805 void func54(string delegate() dg)
806 {
807         dg();
808 }
809 
810 void test54()
811 {
812     string[] k=["adf","AsdfadSF","dfdsfassdf"];
813     foreach(d;k)
814     {
815         printf("%.*s\n", cast(int)d.length, d.ptr);
816         string foo() {assert(d!="");return d;}
817         func54(&foo);
818         func54(delegate string() {assert(d!="");return d;});
819     }
820 }
821 
822 /***************************************************/
823 // https://issues.dlang.org/show_bug.cgi?id=1767
824 
825 class DebugInfo
826 {
827     alias int CVHeaderType ;
828     enum anon:CVHeaderType{ CV_NONE, CV_DOS, CV_NT, CV_DBG }
829 }
830 
831 void test55()
832 {
833 }
834 
835 /***************************************************/
836 
837 template T56() { int i; }
838 
839 struct S56 {
840     alias T56!() data;
841 }
842 
843 class C56 {
844     alias T56!() data;
845 }
846 
847 void test56()
848 {
849     S56.data.i = 3;
850     C56.data.i = 4;
851     assert(S56.data.i == 4);
852 }
853 
854 /***************************************************/
855 
856 void writecrossing(bool goal)
857 {
858     goal ? printf("escape\n") : printf("return\n");
859 }
860 
861 void test57()
862 {
863     writecrossing(true);
864     writecrossing(false);
865 }
866 
867 /***************************************************/
868 
869 void f58(int n) {}
870 void g58(char[] s) {}
871 
872 char[][] a58;
873 
874 class bar58
875 {
876         int i;
877 
878         void func() {
879                 f58(i);
880 
881                 foreach (s; a58) {
882                         if (s == s){}
883                         if (s[0..0] == "" && s[0..0])
884                                 g58(s);
885                 }
886 
887                 f58(i);
888         }
889 }
890 
891 void test58()
892 {
893 }
894 
895 /***************************************************/
896 
897 void test59()
898 {
899     int[] array = new int[5];
900     uint check = 0;
901     foreach (it; array.ptr .. array.ptr + array.length) {
902         ++check;
903     }
904     assert(check == array.length);
905 }
906 
907 /***************************************************/
908 
909 final class Foo60()
910 {
911     void bar()
912     {
913         int baz;
914         baz = 1;
915     }
916 }
917 
918 void test60()
919 {
920     auto foo = new Foo60!();
921 }
922 
923 /***************************************************/
924 
925 class ZipEntry61
926 {
927     ZipEntryInfo61 info;
928     this() {}
929 }
930 struct ZipEntryInfo61 {}
931 
932 void test61()
933 {
934 }
935 
936 /***************************************************/
937 
938 void test62()
939 {
940    int foo() { return 0; }
941    int bar() { return 0; }
942 
943    auto t1 = typeid(typeof(foo));
944    auto t2 = typeid(typeof(bar));
945 
946    t1.tsize();
947 }
948 
949 /***************************************************/
950 
951 struct S63
952 {
953     int a;
954     static int foo()
955     {
956         return a.sizeof;
957     }
958 }
959 
960 void test63()
961 {
962     int x = S63.a.sizeof;
963     assert(x == 4);
964     assert(S63.foo() == 4);
965 }
966 
967 /***************************************************/
968 
969 string[] foo64()
970 {
971     return [[]];
972 }
973 
974 void test64()
975 {
976     auto a = foo64();
977     assert(a.length == 1);
978     assert(a[0].length == 0);
979 }
980 
981 /***************************************************/
982 
983 string[][] foo65()
984 {
985     string[][] result = [];
986     string[] s = [];
987     result ~= [s];
988     return result;
989 }
990 
991 void test65()
992 {
993     auto s = foo65();
994     assert(s.length == 1);
995     assert(s[0].length == 0);
996 }
997 
998 /***************************************************/
999 
1000 string[][] foo66()
1001 {
1002     string[] strings = ["a","bc"];
1003     string [][] result = [];
1004     foreach (s; strings)
1005     {
1006         result ~= [s];
1007     }
1008     return result;
1009 }
1010 
1011 void test66()
1012 {
1013     auto s = foo66();
1014     assert(s.length == 2);
1015     assert(s[0].length == 1);
1016     assert(s[0][0].length == 1);
1017     assert(s[1].length == 1);
1018     assert(s[1][0].length == 2);
1019 }
1020 
1021 /***************************************************/
1022 
1023 template Tuple67(A...)
1024 {
1025     alias A Tuple67;
1026 }
1027 
1028 template Bar67()
1029 {
1030     const s = "a bar";
1031 }
1032 
1033 void test67()
1034 {
1035     alias Tuple67!(Bar67!()) tuple;
1036     static const i = 0;
1037     alias tuple[0] bara;
1038     alias tuple[i] barb;
1039 
1040     static assert(bara.s == "a bar");
1041     static assert(barb.s == "a bar");
1042 }
1043 
1044 /***************************************************/
1045 
1046 template Tuple68(A...)
1047 {
1048     alias A Tuple68;
1049 }
1050 
1051 size_t foo68()
1052 {
1053     return 1;
1054 }
1055 
1056 void test68()
1057 {
1058     alias Tuple68!("one", "two") tuple;
1059     static assert(tuple[foo68()] == "two");
1060 }
1061 
1062 /***************************************************/
1063 
1064 class Base69 {}
1065 
1066 class Da69 : Base69 {}
1067 class Db69 : Base69 {}
1068 
1069 void test69()
1070 {   int i;
1071     auto b = i ? new Da69 : new Db69;
1072     assert(is(typeof(b) == Base69));
1073 }
1074 
1075 /***************************************************/
1076 
1077 struct Bar70
1078 {
1079         Bar70[] bars;
1080 }
1081 
1082 void test70()
1083 {
1084         Bar70 node;
1085 }
1086 
1087 /***************************************************/
1088 
1089 template Foo71(string s)
1090 {
1091     string b = s;
1092 }
1093 
1094 void test71()
1095 {
1096     size_t s = Foo71!(
1097 "helloabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
1098 ~ "helloabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
1099 ~ "helloabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
1100 ~ "helloabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
1101 ~ "helloabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
1102 ~ "helloabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
1103 ~ "helloabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
1104 ~ "helloabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
1105 ~ "helloabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
1106 ~ "helloabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
1107 ~ "helloabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
1108 ~ "When dealing with complex template tuples, it's very easy to overflow the
1109 maximum symbol length allowed by OPTLINK.  This is, simply put, a damn shame,
1110 because it prevents otherwise completely legal code from compiling and linking
1111 with DMDWin, whereas it works perfectly fine when using DMDNix or GDC.
1112 I know that this is neither a simple nor a small issue to fix: either the
1113 ancient, nearly-immutable OPTLINK would have to be modified, or DMDWin would
1114 have to be changed to output a more reasonable format, in which case a new
1115 linker would probably have to be written.  Until then, this issue should stand
1116 as a reminder that DMDWin is inherently limited.
1117 Oplink isn't the issue. The OMF file format has a hard limit. This results in
1118 the only solutions being: convert DMD to use some other .obj format or have DMD
1119 do something else for name mangling.
1120 In talking to Walter, the issue is that it's easy to get symbols that have more
1121 info in them than can be fit into the limit. (the limit has already stretched
1122 by gziping the symbols.)
1123 The simple solution I have proposed is to just MD5 (or what not) the symbols.
1124 The only issue (besides a vanishingly small chance of a hash collision) is that
1125 this looses information so you can't look at a symbol and directly determine
1126 what it was. My answer to that is, who cares? The only place where hashing
1127 provides less info than compressing is in a debugger and it can grab the full
1128 symbol from a table in the static data segment.
1129 I suppose as a stopgap measure that'd work fine, and might even be controlled
1130 by a compiler switch, so that in the general case debugger info wouldn't be
1131 affected.  And what's more -- the only time these issues come up is with
1132 templates, which a lot of debuggers have serious problems with anyway, so..
1133 I would set it up as a method of last resort. It wouldn't be used unless the
1134 symbol can't be used any other way.
1135 "
1136         ).b.length;
1137 }
1138 
1139 /***************************************************/
1140 
1141 class B72 { this(bool b, string c){} }
1142 
1143 class C72 : B72
1144 {
1145         this()
1146         {
1147                 alias typeof(super(false,"hello")) foo;
1148                 super(false,"hello");
1149         }
1150 }
1151 
1152 void test72()
1153 {
1154 }
1155 
1156 /***************************************************/
1157 
1158 template Foo73()
1159 {
1160     mixin ("const int x = 3;");
1161     //const int x = 3;
1162 
1163     static if (x == 3)
1164     {
1165         pragma(msg, "success");
1166     }
1167 }
1168 
1169 alias Foo73!() foo73;
1170 
1171 void test73()
1172 {
1173 }
1174 
1175 /***************************************************/
1176 
1177 alias uint foo74;
1178 
1179 void simple_func_t(T)(T s, foo74 i)
1180 {
1181     assert(s == "hello");
1182     assert(i == 3);
1183 }
1184 
1185 void test74()
1186 {
1187     simple_func_t("hello", 3);
1188 }
1189 
1190 /***************************************************/
1191 
1192 void foo75(T)(T[] x ...)
1193 {
1194     assert(x.length == 3);
1195     assert(x[0] == 2);
1196     assert(x[1] == 3);
1197     assert(x[2] == 4);
1198     assert(is(T == int));
1199 }
1200 
1201 void test75()
1202 {
1203     foo75(2,3,4);
1204 }
1205 
1206 /***************************************************/
1207 
1208 void delegate(U) Curry(A, U...)(void delegate(A,U) dg,A arg)
1209 {
1210   struct ArgRecord {
1211     A arg;
1212     typeof(dg) callback;
1213 
1214     void OpCall(U args) { callback(arg,args); }
1215   }
1216   auto temp = new ArgRecord;
1217   temp.arg = arg;
1218   temp.callback = dg;
1219   return &temp.OpCall;
1220 }
1221 
1222 void delegate(A) Seq(A...)(void delegate(A)[] dgs...)
1223 {
1224   return Curry(delegate void(void delegate(A)[] dgs1,A args)
1225                {
1226                  foreach(dg; dgs1)
1227                    dg(args);
1228                },
1229                dgs);
1230 }
1231 
1232 struct Foo76
1233 {
1234   void fred(int i) {}
1235 }
1236 
1237 void test76()
1238 {
1239   void delegate(int) tmp;
1240   auto bob = new Foo76;
1241   auto dan = new Foo76;
1242 
1243   tmp = Seq!(int)(&bob.fred);             // this works
1244   tmp = Seq!(int)(&bob.fred, &dan.fred);  // this works
1245   tmp = Seq      (&bob.fred);             // this doesn't
1246   tmp = Seq      (&bob.fred, &dan.fred);  // neither does this
1247 }
1248 
1249 /***************************************************/
1250 
1251 int x77;
1252 
1253 void foo77()
1254 {
1255     x77 = 1;
1256 
1257     static if(true)
1258     {
1259     }
1260     else
1261     {
1262     }
1263 }
1264 
1265 void test77()
1266 {
1267     foo77();
1268     assert(x77 == 1);
1269 }
1270 
1271 /***************************************************/
1272 
1273 class Foo78
1274 {
1275   template TBar(T)
1276   {
1277     T x;                   // Compiles, but is implicitly static
1278     void func(T t)   // Ok, non-static member template function
1279     { assert(t == 2); assert(this.bar == 42); }
1280   }
1281   int bar = 42;
1282 }
1283 
1284 void test78()
1285 {
1286   alias Foo78 Foo;
1287   Foo.TBar!(int).x = 2;
1288   //Foo.TBar!(int).func(2); // error, since funcx is not static
1289 
1290   Foo f = new Foo;
1291   Foo g = new Foo;
1292 
1293   f.TBar!(int).func(2); // works
1294 
1295   f.TBar!(int).x = 10;
1296   g.TBar!(int).x = 20;
1297   assert(f.TBar!(int).x == 20); // prints 20
1298 }
1299 
1300 /***************************************************/
1301 
1302 class C79
1303 {
1304 }
1305 
1306 void test79()
1307 {
1308     C79 c = new C79();
1309 //    writeln(c.__vptr);
1310 //    writeln(c.__vptr[0]);
1311 //    writeln(cast(void*)c.classinfo);
1312     assert(c.__vptr[0] == cast(void*)c.classinfo);
1313 //    writeln(c.__monitor);
1314     assert(c.__monitor == null);
1315     synchronized (c)
1316     {
1317 //        writeln(c.__monitor);
1318         assert(c.__monitor !is null);
1319     }
1320 }
1321 
1322 /***************************************************/
1323 
1324 class Test80{
1325   template test(){
1326     enum int test=1;
1327   }
1328 }
1329 
1330 void test80()
1331 {
1332   assert(Test80.test!()==1);
1333   assert((new Test80).test!()==1);
1334 }
1335 
1336 /***************************************************/
1337 
1338 class Test81
1339 {
1340   static const test2=1;
1341   template test(){
1342     static const int test=1;
1343   }
1344 }
1345 
1346 void test81()
1347 {
1348   auto a=new Test81;
1349   static assert(typeof(a).test2==1);//ok
1350   alias typeof(a) t;
1351   static assert(t.test!()==1);//ok
1352   static assert(typeof(a).test!()==1);//syntax error
1353 }
1354 
1355 /***************************************************/
1356 
1357 deprecated
1358 {
1359     alias real A82;
1360     void foo82(A82 x) {    }
1361 }
1362 
1363 void test82()
1364 {
1365 }
1366 
1367 /***************************************************/
1368 
1369 class Bar83
1370 {
1371     deprecated void foo(int param)
1372     {
1373     }
1374 
1375     void foo(string param)
1376     {
1377     }
1378 }
1379 
1380 void test83()
1381 {
1382     Bar83 b = new Bar83;
1383     string str = "bar";
1384     b.foo(str);
1385 }
1386 
1387 /***************************************************/
1388 
1389 void test84()
1390 {
1391     int[0][10] arr;
1392     printf("%tu\n", &arr[9] - &arr[0]);
1393     auto i = &arr[9] - &arr[0];
1394     assert(i == 0);
1395 }
1396 
1397 /***************************************************/
1398 
1399 class myid
1400 {
1401     string buf;
1402     this(string str )
1403     {
1404             buf = str;
1405     }
1406 }
1407 struct Lex
1408 {
1409     static myid myidinst;
1410     static void Init()
1411     {
1412             myidinst = new myid("abc");
1413     }
1414 }
1415 
1416 void test85()
1417 {
1418     Lex.Init();
1419     assert(cast(myid)(Lex.myidinst) !is null);
1420 }
1421 
1422 /***************************************************/
1423 
1424 struct Time
1425 {
1426   long ticks;
1427 }
1428 
1429 struct Stamps
1430 {
1431     Time    created,        /// time created
1432             accessed,       /// last time accessed
1433             modified;       /// last time modified
1434 }
1435 
1436 Stamps getTimeStamps()
1437 {
1438     foreach(i; 0..10) { }
1439     Stamps                    time = void;
1440 
1441     time.modified = Time(20);
1442     time.accessed = Time(20);
1443     time.created  = Time(20);
1444     return time;
1445 }
1446 
1447 Time accessed ()
1448 {
1449     foreach(i; 0..10) { }
1450     return timeStamps(4).accessed;
1451 }
1452 
1453 Stamps timeStamps (int name)
1454 {
1455   return getTimeStamps();
1456 }
1457 
1458 void test86()
1459 {
1460 
1461   assert(accessed().ticks == 20);
1462 }
1463 
1464 /***************************************************/
1465 
1466 const bool foo87 = is(typeof(function void() { }));
1467 const bar87      = is(typeof(function void() { }));
1468 
1469 void test87()
1470 {
1471     assert(foo87 == true);
1472     assert(bar87 == true);
1473 }
1474 
1475 /***************************************************/
1476 
1477 int function() wrap88(void function()) { return null; }
1478 
1479 void test88()
1480 {
1481         printf("test88\n");
1482         if (0)
1483             wrap88(&test88)();
1484 }
1485 
1486 /***************************************************/
1487 
1488 struct S89
1489 {
1490         static const float[2] z = 3;
1491 }
1492 
1493 class C89
1494 {
1495         static const float[2] z = 3;
1496 }
1497 
1498 void bar89(float f) { assert(f == 3); }
1499 
1500 void test89()
1501 {
1502         printf("test89\n");
1503         bar89(S89.z[0]);
1504         bar89(S89.z[1]);
1505         bar89(C89.z[0]);
1506         bar89(C89.z[1]);
1507 }
1508 
1509 /***************************************************/
1510 
1511 void trigger(char[] txt)
1512 {
1513         txt[0] = 'x';
1514 
1515         scope(exit)
1516         {
1517                 txt[0] = 'x';
1518         }
1519 
1520         return;
1521 }
1522 
1523 void test90()
1524 {
1525 }
1526 
1527 /***************************************************/
1528 
1529 void test91()
1530 {
1531     enum ABC { a, b, c }
1532     assert(ABC.stringof == "ABC");
1533 }
1534 
1535 /***************************************************/
1536 
1537 int x92;
1538 
1539 int f92() {
1540     x92++;
1541     return 0;
1542 }
1543 
1544 void test92()
1545 {
1546     int[1] a;
1547     a[f92()] += 42L;
1548     assert(x92 == 1);
1549 }
1550 
1551 /***************************************************/
1552 
1553 void test93()
1554 {
1555     void foo() { }
1556     static assert(is(typeof(1 || foo()) == void));
1557     static assert(is(typeof(1 && foo()) == void));
1558 }
1559 
1560 /***************************************************/
1561 
1562 void foo94(T)()
1563 {
1564 }
1565 
1566 struct f94(alias func=foo94!(int))
1567 {
1568 }
1569 
1570 void test94()
1571 {
1572     f94!() myf;
1573 }
1574 
1575 /***************************************************/
1576 
1577 struct X95
1578 {
1579    import core.stdc.stdio;
1580 }
1581 
1582 void test95()
1583 {
1584    X95.core.stdc.stdio.printf("hello\n");
1585 }
1586 
1587 /***************************************************/
1588 
1589 template foo96(alias bar)
1590 {
1591     pragma(msg, bar.stringof ~ " " ~ typeof(bar).stringof);
1592     static assert((bar.stringof ~ " " ~ typeof(bar).stringof) == "myInt int" ||
1593         (bar.stringof ~ " " ~ typeof(bar).stringof) == "myBool bool");
1594     void foo96() {}
1595 }
1596 
1597 void test96()
1598 {
1599     int myInt;
1600     bool myBool;
1601 
1602     foo96!(myInt)();
1603     foo96!(myBool)();
1604 }
1605 
1606 /***************************************************/
1607 
1608 void test97()
1609 {
1610     const short[] ct = cast(short[]) [cast(byte)1, 1];
1611 //    writeln(ct);
1612     assert(ct.length == 2 && ct[0] == 1 && ct[1] == 1);
1613 
1614     short[] rt = cast(short[]) [cast(byte)1, cast(byte)1].dup;
1615 //    writeln(rt);
1616     assert(rt.length == 1 && rt[0] == 257);
1617 }
1618 
1619 /***************************************************/
1620 
1621 class Foo98
1622 {
1623     string foo = "abc";
1624     size_t i = 0;
1625 
1626     void bar()
1627     {
1628         printf("%c\n", foo[i]);
1629         i++;
1630         printf("%c\n", foo[i]);
1631         assert(foo[i] == 'b');
1632     }
1633 }
1634 
1635 void test98()
1636 {
1637     auto f = new Foo98();
1638     f.bar();
1639 }
1640 
1641 /***************************************************/
1642 
1643 template implicitlyConverts99(S, T)
1644 {
1645     enum bool implicitlyConverts99 = T.sizeof >= S.sizeof
1646         && is(typeof({S s; T t = s;}()));
1647 }
1648 
1649 static assert(!implicitlyConverts99!(long, short));
1650 
1651 void test99()
1652 {
1653 }
1654 
1655 /***************************************************/
1656 
1657 void test100()
1658 {
1659     static void check(ulong value)
1660     {
1661         real r = value;
1662         ulong d = cast(ulong)r;
1663         printf("ulong: %llu => real: %Lg => ulong: %llu\n", value, r, d);
1664         assert(d == value);
1665     }
1666 
1667     // check biggest power of 2 representable in ulong: 2^63
1668     check(1L << 63);
1669 
1670     // check biggest representable uneven number
1671     static if (real.mant_dig >= 64) // > 64: limited by ulong precision
1672         check(ulong.max); // 2^64-1
1673     else
1674         check((1L << real.mant_dig) - 1);
1675 }
1676 
1677 /***************************************************/
1678 
1679 auto e101(int x) { return 5; }
1680 
1681 void test101()
1682 {
1683     assert(is(typeof(e101(3)) == int));
1684 }
1685 
1686 /***************************************************/
1687 
1688 int x103;
1689 
1690 void external(...)
1691 {
1692     int arg = va_arg!int(_argptr);
1693     printf("external: %d\n", arg);
1694     x103 = arg;
1695 }
1696 
1697 class C103
1698 {
1699     void method ()
1700     {
1701         void internal (...)
1702         {
1703             int arg = va_arg!int(_argptr);
1704             printf("internal: %d\n", arg);
1705             x103 = arg;
1706         }
1707 
1708         internal (43);
1709         assert(x103 == 43);
1710     }
1711 }
1712 
1713 void test103()
1714 {
1715     external(42);
1716     assert(x103 == 42);
1717     (new C103).method ();
1718 }
1719 
1720 /***************************************************/
1721 
1722 class C104
1723 {
1724     template Bar()
1725     {
1726     }
1727 }
1728 
1729 static assert(!is(typeof(C104.Bar.foo)));
1730 
1731 void test104()
1732 {
1733 }
1734 
1735 /***************************************************/
1736 
1737 template Templ(T)
1738 {
1739     const char [] XXX = Type.mangleof;
1740     alias T Type;
1741 }
1742 
1743 void test105()
1744 {
1745     Templ!(int).Type x;
1746     auto s = Templ!(int).XXX;
1747     printf("%.*s\n", cast(int)s.length, s.ptr);
1748     assert(s == "i");
1749 }
1750 
1751 /***************************************************/
1752 // rejects-valid 2.012.
1753 
1754 class foo107 {}
1755 alias foo107 bar107;
1756 void x107()
1757 {
1758    bar107 a = new bar107();
1759    bar107 b = new bar107();
1760    bool c = (a == b);
1761 }
1762 
1763 void test107()
1764 {
1765 }
1766 
1767 /***************************************************/
1768 
1769 struct Foo108
1770 {
1771     char[] byLine()()
1772     {
1773         return null;
1774     }
1775 }
1776 
1777 void test108()
1778 {   Foo108 foo;
1779 
1780     foreach (char c; foo.byLine)
1781     {
1782     }
1783 }
1784 
1785 /***************************************************/
1786 
1787 void test109()
1788 {
1789     double[] x = new double[1];
1790     assert(x[0] != 0);
1791 }
1792 
1793 /***************************************************/
1794 
1795 void test110()
1796 {
1797     struct C {
1798         int[0] b;
1799     }
1800     static C g_c2_ = {  };
1801 }
1802 
1803 /***************************************************/
1804 
1805 template Foo111(T...) {
1806     alias T Foo111;
1807 }
1808 
1809 void test111()
1810 {
1811     auto y = (Foo111!(int) x){ return 0; };
1812 }
1813 
1814 /***************************************************/
1815 
1816 bool isNull(string str) {
1817         return str is null;
1818 }
1819 
1820 const bool foo112 = isNull("hello!");
1821 
1822 void test112()
1823 {
1824     assert(!foo112);
1825 }
1826 
1827 /***************************************************/
1828 
1829 void test113()
1830 {
1831   for (int j=1; j<2; j++) {
1832     int x = (j<0) ? -j : j;
1833     int q=0;
1834     for (int i=0; i<x; i++) ++q;
1835     assert(q!=0);
1836   }
1837 }
1838 
1839 /***************************************************/
1840 
1841 struct VariantN
1842 {
1843     static int opCall(int value)
1844     {
1845         return 0;
1846     }
1847 
1848     void foo()
1849     {
1850         VariantN v;
1851         v.bar(42, 5);
1852     }
1853 
1854     void bar(int value, int i)
1855     {
1856         int[2] args = [ VariantN(value), VariantN(i) ];
1857     }
1858 }
1859 
1860 void test114()
1861 {
1862 }
1863 
1864 /***************************************************/
1865 
1866 class B115 : A115!(B115) { }
1867 class A115(T) { }
1868 
1869 void test115()
1870 {
1871 }
1872 
1873 /***************************************************/
1874 
1875 struct Foo116 {
1876     this(U...)(U values)  { }
1877 }
1878 
1879 void test116()
1880 {
1881   new Foo116;
1882 }
1883 
1884 /***************************************************/
1885 
1886 void test117()
1887 {
1888     float f = 7;
1889     f = f * 2;
1890     assert(f == 14);
1891 
1892     double d = 7;
1893     d = d * 2;
1894     assert(d == 14);
1895 
1896     real r = 7;
1897     r = r * 2;
1898     assert(r == 14);
1899 }
1900 
1901 /***************************************************/
1902 
1903 void test118()
1904 {
1905     int foo(real x)
1906     {
1907         real y = -x*-x;
1908         return cast(int)y;
1909     }
1910 
1911     auto i = foo(4.0);
1912     assert(i == 16);
1913 }
1914 
1915 /***************************************************/
1916 
1917 class A119
1918 {
1919     static class B119 : C119.D { }
1920 }
1921 
1922 abstract class C119
1923 {
1924     static class D { }
1925 }
1926 
1927 void test119()
1928 {
1929 }
1930 
1931 /***************************************************/
1932 
1933 class A120 {
1934     class B120 : C120.D { }
1935 }
1936 
1937 class C120 : E120 {
1938     static class D { }
1939 }
1940 
1941 interface E120 { }
1942 
1943 void test120()
1944 {
1945 }
1946 
1947 /***************************************************/
1948 
1949 void test121()
1950 {
1951     static assert(null is null);
1952 }
1953 
1954 /***************************************************/
1955 
1956 T[] find123(alias pred, T)(T[] input) {
1957    while (input.length > 0) {
1958       if (pred(input[0])) break;
1959       input = input[1 .. $];
1960    }
1961    return input;
1962 }
1963 
1964 void test123()
1965 {
1966     int[] a = [ 1, 2, 3, 4, -5, 3, -4 ];
1967     find123!(function bool(int i) { return i < 0; })(a);
1968 }
1969 
1970 
1971 /***************************************************/
1972 
1973 static assert(!is(typeof((){(){}
1974          ;-()
1975 {};})));
1976 
1977 /***************************************************/
1978 
1979 struct Foobar;
1980 
1981 /***************************************************/
1982 
1983 int test124()
1984 {   int result;
1985     dchar[] aa;
1986     alias size_t foo_t;
1987 
1988     foreach (foo_t i, dchar d; aa)
1989     {
1990     }
1991     return result;
1992 }
1993 
1994 /***************************************************/
1995 
1996 int foo125(int x)
1997 {
1998     while (1)
1999     {
2000         if (x)
2001             return 3;
2002         x++;
2003     }
2004 }
2005 
2006 void test125()
2007 {
2008     foo125(4);
2009 }
2010 
2011 /***************************************************/
2012 
2013 int foo126(int x)
2014 {
2015     while (1)
2016     {
2017         if (x)
2018             return 3;
2019         x++;
2020     }
2021     assert(0);
2022 }
2023 
2024 void test126()
2025 {
2026     foo126(4);
2027 }
2028 
2029 /***************************************************/
2030 
2031 struct S127(T, int topology = 1)
2032 {
2033     this(T value) { }
2034 }
2035 
2036 void cons127(int t)(S127!(int, t) tail)
2037 {
2038 }
2039 
2040 void test127()
2041 {
2042     S127!(int)(1);
2043     S127!(int, 1) lst;
2044     cons127(lst);
2045 }
2046 
2047 /***************************************************/
2048 
2049 struct S128(T, int topology = 1)
2050 {
2051     this(T value) { }
2052 }
2053 
2054 void cons128(int t)(S128!(int, t) tail)
2055 {
2056 }
2057 
2058 void test128()
2059 {
2060     S128!(int, 1)(1);
2061     S128!(int) lst;
2062     cons128(lst);
2063 }
2064 
2065 /***************************************************/
2066 
2067 struct R129(R : E[], E)
2068 {
2069     E[] forward;
2070     static R129 opCall(E[] range)
2071     {
2072         R129 result = {};
2073         result.forward =  range;
2074         return result;
2075     }
2076 }
2077 
2078 R129!(E[]) retro129(E)(E[] r)
2079 {
2080     return R129!(E[])(r);
2081 }
2082 
2083 int begin129(F)(R129!(F) range)
2084 {
2085     return 0;
2086 }
2087 
2088 void test129()
2089 {
2090     int[] a = [ 1, 2, 3 ];
2091     auto r = retro129(a);
2092     auto i = begin129(r);
2093 }
2094 
2095 /***************************************************/
2096 // https://issues.dlang.org/show_bug.cgi?id=12725
2097 
2098 struct R12725(R : E[], E)
2099 {
2100 }
2101 
2102 int begin12725(F)(R12725!(F) range)
2103 {
2104     return 0;
2105 }
2106 
2107 void test12725()
2108 {
2109     R12725!(int[], int) r;
2110     auto i = begin12725(r);
2111 }
2112 
2113 /***************************************************/
2114 // https://issues.dlang.org/show_bug.cgi?id=12728
2115 
2116 struct Matrix12728(T, uint m, uint n = m, ubyte f = 0)
2117 {
2118     void foo(uint r)(auto ref in Matrix12728!(T, n, r) b)
2119     {
2120     }
2121 }
2122 
2123 void test12728()
2124 {
2125     alias Matrix4 = Matrix12728!(float, 4);
2126 
2127     Matrix4 m;
2128     m.foo(m);
2129 }
2130 
2131 /***************************************************/
2132 
2133 struct S130
2134 {
2135   byte[3] x;
2136 }
2137 
2138 __gshared S130 e130;
2139 
2140 const(S130) example130() { return e130; }
2141 
2142 void test130()
2143 {
2144 }
2145 
2146 /***************************************************/
2147 
2148 void foo131(real z) {}
2149 
2150 void test131()
2151 {
2152     real F = 1;
2153     foo131( 1 + (F*3*2.1) );
2154 }
2155 
2156 /***************************************************/
2157 
2158 float getFloat() {
2159     return 11468.78f;
2160 }
2161 
2162 void test132()
2163 {
2164     uint i = cast(uint) 11468.78f;
2165     assert(i == 11468);
2166 
2167     uint j = cast(uint) getFloat();
2168     assert(j == 11468);
2169 }
2170 
2171 /***************************************************/
2172 
2173 template T133(string s) {
2174     const string T133 = s;
2175 }
2176 
2177 string f133(string s) {
2178     return s;
2179 }
2180 
2181 void test133()
2182 {
2183     int foo;
2184     //writeln(foo.stringof);
2185     assert ("foo" == f133(foo.stringof));
2186     assert ("foo" == T133!(foo.stringof));
2187 }
2188 
2189 /***************************************************/
2190 
2191 public struct foo134
2192 {
2193     public this(real aleft)
2194     {
2195     }
2196 }
2197 
2198 class bar134
2199 {
2200     final void fun(foo134 arg = foo134(0.)) { }
2201 }
2202 
2203 /***************************************************/
2204 
2205 void test135()
2206 {
2207     char[char[3]] ac;
2208     char[3] c = "abc";
2209     ac["abc"]='a';
2210     assert(ac[c]=='a');
2211 
2212     char[dchar[3]] ad;
2213     dchar[3] d = "abc"d;
2214     ad["abc"d]='a';
2215     assert(ad[d]=='a');
2216 }
2217 
2218 /***************************************************/
2219 
2220 void test136()
2221 {
2222     struct S { int[3] i; }
2223     enum S s = S(8);
2224     const int i  = s.i[2];
2225     assert(i == 8);
2226 }
2227 
2228 /***************************************************/
2229 
2230 struct Particle {
2231     char[16] name;
2232 }
2233 
2234 class ReadSystem {
2235     size_t[char[16]] pKindsIdx;
2236 
2237     void t(Particle p)
2238     {   auto idx=p.name in pKindsIdx;
2239     }
2240 }
2241 
2242 void test137()
2243 {
2244     char[16] n;
2245     size_t[char[16]] aa;
2246     auto r=n in aa; // works
2247 }
2248 
2249 /***************************************************/
2250 
2251 long test138(int y)
2252 {
2253     return *cast(long*)(&y);
2254 }
2255 
2256 /***************************************************/
2257 
2258 void test139()
2259 {
2260    auto famousNamedConstants =
2261     [ "pi" : 3.14, "e" : 2.71, "moving sofa" : 2.22 ];
2262 
2263     assert(famousNamedConstants["e"]==2.71);
2264 }
2265 
2266 /***************************************************/
2267 
2268 int* get140()  {  return (new int[4]).ptr; }
2269 
2270 void test140()
2271 {
2272   int* p = get140();
2273   p[0..3] = 0;
2274   p[0] = 7;
2275 }
2276 
2277 /***************************************************/
2278 
2279 class Foo141 {
2280     Foo141 next;
2281     void start()
2282     in { assert (!next); } do
2283     {
2284         void* p = cast(void*)this;
2285     }
2286 }
2287 
2288 /***************************************************/
2289 
2290 void a142(int b = 1+2)(){};
2291 
2292 void test142()
2293 {
2294     a142!(1+2)();
2295     a142();
2296 }
2297 
2298 /***************************************************/
2299 
2300 class A143
2301 {
2302     invariant() { }
2303     void fill() { }
2304 }
2305 
2306 
2307 class B143 : A143
2308 {
2309     override void fill() { }
2310 }
2311 
2312 void test143()
2313 {
2314     auto b = new B143();
2315     b.fill();
2316 }
2317 
2318 /***************************************************/
2319 
2320 struct Pair
2321 {
2322     static Pair opCall(uint a, uint b) { return Pair.init; }
2323 }
2324 
2325 struct Stack
2326 {
2327     Pair pop() { return Pair.init; }
2328 }
2329 
2330 void test144()
2331 {
2332     Stack stack;
2333     Pair item = stack.pop;
2334 }
2335 
2336 /***************************************************/
2337 
2338 struct Ashes {
2339     int ashes = cast(int)0;
2340 }
2341 void funky (Ashes s = Ashes()) { }
2342 
2343 struct S145 {
2344     real a = 0, b = 0;
2345 }
2346 
2347 void func145(S145 s = S145()) { }
2348 
2349 void test145()
2350 {
2351     funky();
2352     func145();
2353 }
2354 
2355 /***************************************************/
2356 
2357 string foo146(T...)(T args)
2358 {
2359     string ret;
2360 
2361     foreach(arg; args) {
2362         ret = arg;
2363     }
2364 
2365     assert(ret=="b"); // passes
2366     return ret;
2367 }
2368 
2369 void test146()
2370 {
2371     string s = foo146("b");
2372     assert(s == "b"); // fails
2373 }
2374 
2375 /***************************************************/
2376 
2377 void test147()
2378 {
2379     string s = "foo";
2380     dchar c = 'x';
2381     s ~= c;
2382     assert(s == "foox");
2383 
2384     wstring ws = "foo";
2385     ws ~= c;
2386     assert(ws == "foox");
2387 }
2388 
2389 /***************************************************/
2390 
2391 void test148()
2392 {
2393     string a = "\U00091234";
2394     string b;
2395 
2396     b ~= "\U00091234";
2397 
2398     if (a != b) {
2399             assert(0);
2400     }
2401 }
2402 
2403 /***************************************************/
2404 
2405 void test149()
2406 {
2407   long[1] b = void;
2408   b[0] = -1L;
2409   b[0] >>>= 2;
2410   assert( (b[0]) == 0x3FFFFFFFFFFFFFFFL);
2411 }
2412 
2413 /***************************************************/
2414 
2415 bool foo150()
2416 {
2417     int x;
2418     return cast(void*) (x & 1) == null;
2419 }
2420 
2421 /***************************************************/
2422 // https://issues.dlang.org/show_bug.cgi?id=3521
2423 
2424 void crash(int x)
2425 {
2426     if (x==200) return;
2427     assert(0);
2428 }
2429 
2430 void test151()
2431 {
2432     int x;
2433     bug3521(&x);
2434 }
2435 
2436 void bug3521(int *a)
2437 {
2438     int c = 0;
2439     *a = 0;
2440     if ( *a || (*a != (c = 200)) )
2441         crash(c);
2442 }
2443 
2444 /***************************************************/
2445 
2446 string foo152(T...)() {
2447     return "";
2448 }
2449 
2450 void test152() {
2451     foo152!(int, char)();
2452 }
2453 
2454 /***************************************************/
2455 
2456 int get_value()
2457 {
2458     return 1;
2459 }
2460 
2461 int[2] array1;
2462 int[2] array2;
2463 
2464 int foo153(ulong a1, ulong extra, ulong extra2, ulong extra3)
2465 {
2466     if (!((a1 & 1) | (get_value() | array1[cast(uint)(a1^1)])))
2467         return 0;
2468 
2469     if (0 >= array2[cast(uint)(a1^1)])
2470         return 0;
2471 
2472     return 1;
2473 }
2474 
2475 void test153()
2476 {
2477     foo153(0, 0, 0, 0);
2478 }
2479 
2480 /***************************************************/
2481 
2482 class B154 : A154
2483 {
2484 }
2485 
2486 enum SomeEnum
2487 {
2488     EnumMember = 10
2489 }
2490 
2491 class A154
2492 {
2493     SomeEnum someEnum()
2494     {
2495         return SomeEnum.EnumMember;
2496     }
2497 }
2498 
2499 void test154()
2500 {
2501     auto b = new B154();
2502     assert(cast(int)b.someEnum == 10);
2503 }
2504 
2505 /***************************************************/
2506 
2507 struct Qwert {
2508     Yuiop.Asdfg hjkl;
2509 }
2510 
2511 struct Yuiop {
2512     struct Asdfg {
2513         int zxcvb;
2514     }
2515 }
2516 
2517 /***************************************************/
2518 
2519 void f156(Value156.Id t)
2520 {
2521     assert(cast(int)t == 1);
2522 }
2523 
2524 struct Value156 {
2525   public static enum Id {
2526     A,
2527     B
2528   }
2529 }
2530 
2531 void test156()
2532 {
2533   Value156.Id t = Value156.Id.B;
2534   f156(t);
2535 }
2536 
2537 /***************************************************/
2538 
2539 X157 x157;
2540 enum X157 { Y };
2541 
2542 interface Foo157 {
2543     Policy157 fn();
2544 }
2545 
2546 enum Policy157 {Default, Cached, Direct}
2547 
2548 void test157()
2549 {
2550 }
2551 
2552 /***************************************************/
2553 
2554 class X158 {
2555   Y158.NY t;
2556   enum NX { BLA, BLA1 }
2557 }
2558 
2559 class Y158 {
2560   enum NY { FOO, BAR }
2561   X158.NX nx;
2562 }
2563 
2564 /***************************************************/
2565 
2566 struct Foo159 {
2567     Bar.Baz x;
2568 
2569     struct Bar {
2570         struct Baz {}
2571     }
2572 }
2573 
2574 /***************************************************/
2575 
2576 void test160()
2577 {
2578   long[1] b = void;
2579   b[0] = -1L;
2580   b[0] >>>= 2;
2581   assert( (b[0]) == 0x3FFFFFFFFFFFFFFFL);
2582   int i = -1;
2583   assert(i >>>2 == 0x3FFFFFFF);
2584 }
2585 
2586 /***************************************************/
2587 
2588 class A161 {
2589     struct B {
2590         D161 x;
2591 
2592         struct C {}
2593     }
2594 }
2595 
2596 
2597 struct D161 {}
2598 
2599 class C161
2600 {
2601     A a;
2602 
2603     struct A
2604     {
2605         uint m;
2606     }
2607 
2608     enum
2609     {
2610         E = 0
2611     }
2612 }
2613 
2614 /***************************************************/
2615 
2616 interface A162
2617 {
2618     C162 foo();
2619     C162 foo() const;
2620 }
2621 
2622 class B162 : A162
2623 {
2624     C162 foo() { return null; }
2625     C162 foo() const { return null; }
2626 }
2627 
2628 abstract class C162 : A162
2629 {
2630     C162 foo() { return null; }
2631     C162 foo() const { return null; }
2632 }
2633 
2634 /***************************************************/
2635 
2636 void func163( A... )( string name, string v )
2637 {
2638 }
2639 
2640 void test163()
2641 {
2642     func163!( int, long, float )( "val", "10" );
2643     func163!()( "tmp", "77" );
2644     alias func163!() TMP; TMP( "tmp", "77" );
2645 }
2646 
2647 /***************************************************/
2648 
2649 class A164
2650 {
2651     B164 foo() { return null; }
2652     B164 foo() const { return null; }
2653 }
2654 
2655 abstract class B164 : A164
2656 {
2657     override final B164 foo() { return null; }
2658     override final B164 foo() const { return null; }
2659 }
2660 
2661 /***************************************************/
2662 
2663 class A165
2664 {
2665     B165 foo() { return null; }
2666     const(B165) foo() const { return null; }
2667 }
2668 
2669 abstract class B165 : A165
2670 {
2671     override final B165 foo() { return null; }
2672     override final const(B165) foo() const { return null; }
2673 }
2674 
2675 /***************************************************/
2676 
2677 struct A166 {
2678    B166  xxx;
2679    static this () { }
2680 }
2681 
2682 struct B166 {}
2683 
2684 /***************************************************/
2685 
2686 void x168(T)() {
2687     static assert(false);
2688 }
2689 
2690 template y168(T) {
2691     const bool y168 = is(typeof( { x168!(T)(); } ));
2692 }
2693 
2694 static assert(!y168!(int));
2695 
2696 /***************************************************/
2697 
2698 void test169()
2699 {
2700     int AssociativeArray;
2701     int[int] foo;
2702     foreach (x; foo)    {    }
2703 }
2704 
2705 /***************************************************/
2706 
2707 FwdEnum this_fails;
2708 
2709 enum : int
2710 {
2711         E170 =  2
2712 }
2713 
2714 enum FwdEnum : int
2715 {
2716         E2 =  E170
2717 }
2718 
2719 /***************************************************/
2720 // https://issues.dlang.org/show_bug.cgi?id=3740
2721 
2722 abstract class Address {
2723     abstract int nameLen();
2724 }
2725 
2726 class Class171 : Address {
2727     FwdStruct z;
2728 
2729     struct FwdStruct  {  }
2730 
2731     override int nameLen()    { return 0; }
2732 }
2733 
2734 void test171 ()
2735 {
2736     Class171 xxx = new Class171;
2737     assert(typeid(Class171).vtbl.length - typeid(Object).vtbl.length == 1);
2738 }
2739 
2740 /***************************************************/
2741 
2742 struct Foo172
2743 {
2744     enum bool BAR = is (typeof({}()));
2745     static assert (BAR == is (typeof({}())));
2746 }
2747 
2748 /***************************************************/
2749 
2750 const char[][ 89 ] ENUM_NAME = [ 1:"N0" ];
2751 
2752 void test173()
2753 {
2754     switch(`Hi`.dup) {
2755         case ENUM_NAME[1]:
2756         default:
2757                 break;
2758     }
2759 }
2760 
2761 /***************************************************/
2762 
2763 class A174 {
2764     void x() {  }
2765 }
2766 
2767 class B174 : A174 {
2768     override void x() {
2769         assert(0);
2770     }
2771     final void do_x() {
2772         super.x();
2773     }
2774 }
2775 
2776 void test174()
2777 {
2778     auto b = new B174();
2779     b.do_x();
2780 }
2781 
2782 /***************************************************/
2783 
2784 void badvariadic(...) {}
2785 
2786 static assert(!is(typeof(mixin(badvariadic()))));
2787 
2788 /***************************************************/
2789 
2790 struct Foo176
2791 {
2792     int x;
2793 }
2794 
2795 Foo176 getFoo(Foo176 irrelevant)
2796 {
2797     Foo176 p = Foo176(400);
2798     if ( p.x > p.x )
2799         return irrelevant;
2800     else
2801         return p;
2802 }
2803 
2804 void test176()
2805 {
2806    assert(getFoo( Foo176(0) ).x == 400);
2807 }
2808 
2809 /***************************************************/
2810 
2811 int test177()
2812 {
2813     long[1] c = [0]; // must be long
2814 
2815     int [1] d = [1];
2816     int k = 0;
2817     if (!d[0])
2818        k = 1;
2819     k = d[0] + k + k;
2820 
2821     if (c[0]) assert(c[0]);
2822 
2823     return k;
2824 }
2825 
2826 /***************************************************/
2827 
2828 struct S178 {
2829     int x;
2830 
2831     template T(int val) {
2832         enum S178 T = { val };
2833     }
2834 }
2835 
2836 const x178 = S178.T!(0);
2837 
2838 /***************************************************/
2839 
2840 double[100_000] arr = 0.0;
2841 
2842 /***************************************************/
2843 
2844 alias ireal BUG3919;
2845 alias typeof(BUG3919.init*BUG3919.init) ICE3919;
2846 alias typeof(BUG3919.init/BUG3919.init) ICE3920;
2847 
2848 /***************************************************/
2849 
2850 struct S179 {
2851     char a, b, c, d;
2852 }
2853 
2854 void show(char[] args...) {
2855     assert(args[0]=='A');
2856     assert(args[1]=='L');
2857     assert(args[2]=='D');
2858     assert(args[3]=='O');
2859 }
2860 
2861 void A179( S179 ss ) {
2862     show( ss.a, ss.b, ss.c, ss.d );
2863 }
2864 
2865 void test179()
2866 {
2867     S179 ss3;
2868     ss3.a = 'A';
2869     ss3.b = 'L';
2870     ss3.c = 'D';
2871     ss3.d = 'O';
2872     A179( ss3 );
2873 }
2874 
2875 /***************************************************/
2876 
2877 struct XY { union { int x, y; } }
2878 struct AHolder {
2879     XY aa;
2880     void a(XY x) { aa = x; }
2881 }
2882 struct AB {
2883     AHolder aHolder;
2884     XY b;
2885     void a(XY x) { aHolder.a(x); }
2886 }
2887 struct Main {
2888     AB ab;
2889 
2890     void setB() { ab.b = XY(); }
2891     void f() {
2892         ab.a(XY.init);
2893         setB();
2894     }
2895 }
2896 
2897 /***************************************************/
2898 
2899 void fooa181(int x, int y, int[0] a, int z, int t)
2900 {
2901     if (!(x == 2 && y == 4 && z == 6 && t == 8))
2902         assert(0);
2903 }
2904 
2905 void foob181(int x, int y, int[0] a)
2906 {
2907     if (!(x == 2 && y == 4))
2908         assert(0);
2909 }
2910 
2911 void fooc181(int[0] a, int x, int y)
2912 {
2913     if (!(x == 2 && y == 4))
2914         assert(0);
2915 }
2916 
2917 void food181(int[0] a)
2918 {
2919 }
2920 
2921 void test181()
2922 {
2923     int[0] arr = 0;
2924     fooa181(2, 4, arr, 6, 8);
2925     foob181(2, 4, arr);
2926     fooc181(arr, 2, 4);
2927     food181(arr);
2928 }
2929 
2930 /***************************************************/
2931 // https://issues.dlang.org/show_bug.cgi?id=4042
2932 
2933 template isQObjectType(T)
2934 {
2935     enum isQObjectType = is(T.__isQObjectType);
2936 }
2937 
2938 template QTypeInfo(T)
2939 {
2940     static if (!isQObjectType!T)
2941     {
2942         enum size = T.sizeof;
2943     }
2944 }
2945 
2946 struct QList(T)
2947 {
2948     alias QTypeInfo!T TI;
2949     int x;
2950 
2951     void foo()
2952     {
2953         x++;
2954     }
2955 }
2956 
2957 void exec(QList!(QAction) actions) {}
2958 
2959 interface IQGraphicsItem
2960 {
2961 }
2962 
2963 abstract
2964         class QGraphicsObject : IQGraphicsItem
2965 {
2966 }
2967 
2968 class QGraphicsWidget : QGraphicsObject
2969 {
2970 }
2971 
2972 class QAction
2973 {
2974     void associatedGraphicsWidgets(QList!(QGraphicsWidget) a)
2975     {
2976         QList!(QGraphicsWidget) x;
2977     }
2978 }
2979 
2980 void test182()
2981 {
2982 }
2983 
2984 /***************************************************/
2985 
2986 enum { a183 = b183() }
2987 
2988 int b183() { return 0; }
2989 
2990 /***************************************************/
2991 
2992 struct Z184 {
2993     int bar = 1;
2994     union { Foo184 foo; }
2995 }
2996 
2997 struct Foo184 { size_t offset = 0;}
2998 
2999 /***************************************************/
3000 
3001 struct BB185
3002 {
3003   Item185[1] aa;
3004 }
3005 
3006 struct CC185
3007 {
3008   Item185 aa;
3009 }
3010 
3011 struct Item185
3012 {
3013   byte data;
3014 }
3015 
3016 /***************************************************/
3017 
3018 const PM_QS_INPUT = QS_INPUT;
3019 const QS_INPUT = 2;
3020 
3021 /***************************************************/
3022 
3023 alias A187 B187;
3024 const int A187 = 1;
3025 
3026 /***************************************************/
3027 
3028 int foo188(int[3] s)
3029 {
3030     return s[0] + s[1] + s[2];
3031 }
3032 
3033 void test188()
3034 {
3035     int[3] t = [1,3,4];
3036     auto i = foo188(t);
3037     if (i != 8)
3038         assert(0);
3039 }
3040 
3041 /***************************************************/
3042 
3043 template X189(alias fn) {
3044     alias typeof(fn) X189;
3045 }
3046 
3047 void a189()(T1189 x) {
3048     alias X189!(T1189.foo) P; //line 7
3049 
3050     x.foo();
3051 }
3052 
3053 class T1189 {
3054     void foo() {
3055         printf("T1.foo()\n");
3056     }
3057 }
3058 
3059 class T2189 : T1189 {
3060     void bla() {
3061         printf("T2.blah()\n");
3062         assert(false); //line 19
3063     }
3064 }
3065 
3066 void test189() {
3067     a189!()(new T2189());
3068 }
3069 
3070 /***************************************************/
3071 
3072 void test190()
3073 {
3074     string s;
3075 
3076     if (true) scope(exit) s ~= "a";
3077     if (false) { } else scope(exit) s ~= "b";
3078     if (true) scope(exit) scope(exit) s ~= "c";
3079     foreach(x; 1..2) scope(exit) s ~= "d";
3080     if (true) L1: scope(exit) s ~= "e";
3081     do scope(exit) s ~= "f"; while (false);
3082     int i; while (++i == 1) scope(exit) s ~= "g";
3083     try { } finally scope(exit) s ~= "h";
3084     assert(s == "abcdefgh");
3085 }
3086 
3087 /***************************************************/
3088 
3089 struct S191 {
3090   int last = 0;
3091   S191 opCall(int i) {
3092     printf("%d %d\n", last, i);
3093     assert(i == 1 && last == 0 || i == 2 && last == 1 || i == 3 && last == 1);
3094     last = i;
3095     return this;
3096   }
3097 }
3098 
3099 void test191()
3100 {
3101   S191 t;
3102   t(1)(2);
3103   t(3);
3104 }
3105 
3106 /***************************************************/
3107 
3108 enum foo192 {
3109     item,
3110 }
3111 
3112 //pragma(msg, foo.mangleof);
3113 static assert(foo192.mangleof == "E6test426foo192");
3114 
3115 /***************************************************/
3116 
3117 void test193()
3118 {
3119     enum Shapes
3120     {
3121         Circle, Square
3122     }
3123 
3124     int i;
3125     Shapes s;
3126 
3127     pragma(msg, i.stringof);
3128     pragma(msg, s.stringof);
3129 
3130     static assert(i.stringof == "i");
3131     static assert(s.stringof == "s");
3132 }
3133 
3134 /***************************************************/
3135 
3136 void test194()
3137 {
3138     uint[][] b = [[ 1, 2, ]];
3139 }
3140 
3141 /***************************************************/
3142 
3143 alias int T195;
3144 
3145 class C195
3146 {
3147     int yum = x195;
3148 }
3149 
3150 const T195 x195 = 0;
3151 
3152 /***************************************************/
3153 
3154 union A196 {
3155     double[2] a;
3156     double[2] b;
3157 }
3158 
3159 union B196 {
3160 public:
3161      double[2] a;
3162      double[2] b;
3163 }
3164 
3165 static assert(A196.sizeof == B196.sizeof);
3166 
3167 /***************************************************/
3168 
3169 template Compileable(int z) { bool OK;}
3170 
3171 struct Bug3569 {
3172     int bar() { return 7; }
3173 }
3174 
3175 struct Bug3569b {
3176     Bug3569 foo;
3177     void crash() {
3178         static assert(!is(typeof(Compileable!(foo.bar()))));
3179         static assert(!is(typeof(Compileable!((foo = Bug3569.init).bar()))));
3180     }
3181 }
3182 
3183 void test197()
3184 {
3185 }
3186 
3187 /***************************************************/
3188 
3189 void test198()  // https://issues.dlang.org/show_bug.cgi?id=4506
3190 {
3191     int c = 1;
3192     for (int k = 0; k < 2; k++) {
3193         assert((k == 0 && c == 1) || (k == 1 && c == -1));
3194         c *= -1;
3195     }
3196 }
3197 
3198 /***************************************************/
3199 
3200 // https://issues.dlang.org/show_bug.cgi?id=4514
3201 void g199(void delegate(void*, void*) d) { }
3202 
3203 struct X199 {
3204     void f(void*, void*) {}
3205     void n()
3206     {
3207         g199(&f);
3208     }
3209 }
3210 
3211 /***************************************************/
3212 // https://issues.dlang.org/show_bug.cgi?id=4443
3213 
3214 struct Struct4443
3215 {
3216     int x;
3217     char[5] unused;
3218 }
3219 
3220 void foo4443(Struct4443 *dest, Struct4443[] arr)
3221 {
3222     int junk = arr[$-1].x;
3223     if (dest || arr[$-1].x) {
3224         *dest = arr[$-1];
3225     }
3226 }
3227 
3228 void test200()
3229 {
3230     Struct4443[1] a;
3231     Struct4443 info;
3232     foo4443(&info, a);
3233 }
3234 
3235 /***************************************************/
3236 
3237 // https://issues.dlang.org/show_bug.cgi?id=2931
3238 
3239 struct Bug2931 {
3240     int[4][3] val;
3241 }
3242 
3243 struct Outer2931 {
3244         Bug2931 p = Bug2931(67);  // Applies to struct static initializers too
3245         int zoom = 2;
3246         int move = 3;
3247         int scale = 4;
3248 }
3249 
3250 int bug2931()
3251 {
3252   Outer2931 v;
3253   assert(v.move==3);
3254   assert(v.scale == 4);
3255   return v.zoom;
3256 }
3257 
3258 int bug2931_2()
3259 {
3260   Outer2931 v;
3261   Bug2931 w = Bug2931(68);
3262   assert(v.move==3);
3263   for (int i = 0; i < 4; i++)
3264   {
3265     for (int j = 0; j < 3; j++)
3266     {
3267         assert(w.val[j][i] == 68);
3268         assert(v.p.val[j][i] == 67);
3269     }
3270   }
3271   assert(v.scale == 4);
3272   return v.zoom;
3273 }
3274 
3275 static assert(bug2931()==2);
3276 
3277 void test201() {
3278     assert(bug2931()==2);
3279     assert(bug2931_2()==2);
3280 }
3281 
3282 
3283 /***************************************************/
3284 // This was the original varargs example in std.vararg
3285 
3286 
3287 void foo202(int x, ...) {
3288     printf("%zd arguments\n", _arguments.length);
3289     for (int i = 0; i < _arguments.length; i++) {
3290         int j = va_arg!(int)(_argptr);
3291         printf("\t%d\n", j);
3292         assert(j == i + 2);
3293     }
3294 }
3295 
3296 void fooRef202(ref int x, ...) {
3297     printf("%zd arguments\n", _arguments.length);
3298     for (int i = 0; i < _arguments.length; i++) {
3299         int j = va_arg!(int)(_argptr);
3300         printf("\t%d\n", j);
3301         assert(j == i + 2);
3302     }
3303 }
3304 
3305 void test202()
3306 {
3307     foo202(1, 2, 3, 4, 5);
3308 
3309     printf("---\n");
3310 
3311     int x = 1;
3312     fooRef202(x, 2, 3, 4, 5);
3313 }
3314 
3315 /***************************************************/
3316 // https://issues.dlang.org/show_bug.cgi?id=1418
3317 
3318 class A203
3319 {
3320     char name = 'A';
3321     class B203
3322     {
3323         char name = 'B';
3324     }
3325 }
3326 
3327 void test203()
3328 {
3329     class C203
3330     {
3331     char name = 'C';
3332     }
3333 
3334     auto a = new A203;
3335     auto b = a..new B203;
3336     auto c = new C203;
3337 
3338 //    writeln(a.tupleof); // prints: A
3339 //    writeln(b.tupleof); // prints: B main.A
3340 //    writeln(c.tupleof); // prints: C 0000
3341     assert(a.tupleof.length == 1 && a.tupleof[0] == 'A');
3342     assert(b.tupleof.length == 1 && b.tupleof[0] == 'B');
3343     assert(c.tupleof.length == 1 && c.tupleof[0] == 'C');
3344 }
3345 
3346 /***************************************************/
3347 // https://issues.dlang.org/show_bug.cgi?id=4516
3348 
3349 struct A204 { B204 b; }
3350 enum B204 { Z }
3351 
3352 /***************************************************/
3353 // https://issues.dlang.org/show_bug.cgi?id=4503
3354 
3355 class Collection205(T) { }
3356 ICollection c;
3357 
3358 alias Collection205!int ICollection;
3359 
3360 /***************************************************/
3361 
3362 enum TaskStatus:int { Building=-1, }
3363 
3364 TaskStatus test206(char[] s){
3365     char[] t="TaskStatus".dup;
3366     if (s.length>t.length && s[0..t.length]==t){
3367         long res=0;
3368         if (s[t.length]=='-') res= -res;        // <= OPnegass
3369         return cast(TaskStatus)cast(int)res;
3370     }
3371     assert(0);
3372 }
3373 
3374 /***************************************************/
3375 
3376 struct UN {   double dd;    long ll; }
3377 bool cmp( UN * pU ) {   return pU.dd >= pU.ll ? true : false; }
3378 
3379 struct UN2 {  real dd; long ll; }
3380 bool cmp2( UN2 * pU ) {  return pU.dd >= pU.ll ? true : false; }
3381 
3382 struct UN3 {  double dd; int ll; }
3383 bool cmp3( UN3 * pU ) {  return pU.dd >= pU.ll ? true : false; }
3384 
3385 void test207()
3386 {
3387    static UN u = { 10.50, 10 };
3388    auto i = cmp(&u);
3389    printf( "%d\n", cmp( &u ) );
3390    assert(i);
3391 
3392    static UN2 u2 = { 10.50, 10 };
3393    i = cmp2(&u2);
3394    assert(i);
3395 
3396    static UN3 u3 = { 10.50, 10 };
3397    i = cmp3(&u3);
3398    assert(i);
3399 
3400    static UN3 u3_1 = { 9.50, 10 };
3401    i = cmp3(&u3_1);
3402    assert(!i);
3403 }
3404 
3405 /***************************************************/
3406 
3407 template fail4302() {
3408     static assert(0);
3409 }
3410 template bug4302() {
3411    alias fail4302!() bad;
3412 }
3413 static if (is(bug4302!())) {}
3414 
3415 /***************************************************/
3416 
3417 template tough4302()
3418 {
3419   template bar()
3420   {
3421      template far()
3422      {
3423          static assert(0);
3424      }
3425      alias far!() par;
3426   }
3427   static if (is(bar!())) {}
3428 }
3429 
3430 alias tough4302!() tougher;
3431 
3432 /***************************************************/
3433 
3434 template Bug6602A(T) {
3435   Bug6602B!(T).Result result;
3436 }
3437 
3438 template Bug6602B(U) {
3439   static assert(is(U == int));
3440   alias bool Result;
3441 }
3442 
3443 enum bug6602Compiles = __traits(compiles, Bug6602A!short);
3444 
3445 /***************************************************/
3446 // https://issues.dlang.org/show_bug.cgi?id=3493
3447 
3448 const bar209 = foo209;
3449 const int * foo209 = null;
3450 
3451 /***************************************************/
3452 // https://issues.dlang.org/show_bug.cgi?id=3418
3453 
3454 void test210()
3455 {
3456     ulong a = 1;
3457     a = cast(ulong)(a * 2.0L);
3458 }
3459 
3460 /***************************************************/
3461 
3462 static assert(!is(typeof(Object.tupleof[2000]=0)));
3463 
3464 /***************************************************/
3465 
3466 struct Ghost {}
3467 
3468 void bug4430(T)(int x)   {}
3469 void bug4430(T)(Ghost x) {}
3470 
3471 void test212()
3472 {
3473     bug4430!(char)( 777 );
3474 }
3475 
3476 /***************************************************/
3477 // https://issues.dlang.org/show_bug.cgi?id=4768
3478 
3479 struct A213 { B213 b; }
3480 enum B213 { Z213 = 2 }
3481 
3482 void test213()
3483 {
3484    A213 x;
3485    assert(x.b == 2);
3486 }
3487 
3488 /***************************************************/
3489 
3490 void g214(int j) { }
3491 
3492 void test214()
3493 {
3494     struct S
3495     {
3496         int i;
3497         void f() { g214(i); }
3498     }
3499     auto s = S();
3500 }
3501 
3502 /***************************************************/
3503 
3504 template Q(s...) { alias s q; }
3505 
3506 void test215()
3507 {
3508     class C {}
3509     enum assocarrayliteral = Q!( [1:2] ).q.stringof;
3510     enum complex80 = Q!( 1+1.0i ).q.stringof;
3511     //enum dottype = Q!( C.Object.toString ).q.stringof;
3512     enum halt = 0.stringof;    // ICE w/ -release
3513     //enum remove = Q!( [1:2].remove(1) ).q.stringof;
3514     enum templat = Q!( Q ).q.stringof;
3515 }
3516 
3517 /***************************************************/
3518 // https://issues.dlang.org/show_bug.cgi?id=4941
3519 
3520 template T216(_...) { alias _ T216; }
3521 size_t mid216(size_t n) { return n/2; }
3522 
3523 alias T216!(int, int)[0 .. mid216($)] A216;
3524 alias T216!(1, 2, 3)[0 .. mid216($)] B216;
3525 
3526 void test216()
3527 {
3528     T216!(int, int, int) values;
3529     auto slice = values[0 .. mid216($)];   // C
3530 }
3531 
3532 /***************************************************/
3533 
3534 int bug4529a() { return 0; }
3535 int function() bug4529b;
3536 auto ivorBomb1 = typeid(typeof(bug4529a));
3537 auto ivorBomb2 = typeid(typeof(bug4529b));
3538 
3539 /***************************************************/
3540 
3541 void bug5218c(char [3] s) {}
3542 void bug5218w(wchar [3] s) {}
3543 void bug5218d(dchar [3] s) {}
3544 
3545 void test217()
3546 {
3547     bug5218c("abc");
3548     bug5218w("abc"w);
3549     bug5218d("abc"d);
3550 }
3551 
3552 /***************************************************/
3553 // https://issues.dlang.org/show_bug.cgi?id=2954
3554 
3555 void test218()
3556 {
3557     char[char[3]] ac;
3558     char[3] c = "abc";
3559     ac["abc"]='a';
3560     assert(ac[c]=='a');
3561 
3562     char[dchar[3]] ad;
3563     dchar[3] d = "abc"d;
3564     ad["abc"d]='a';
3565     assert(ad[d]=='a');
3566 }
3567 
3568 /***************************************************/
3569 // https://issues.dlang.org/show_bug.cgi?id=2206
3570 
3571 template T219(U) {
3572   class C {}
3573 }
3574 
3575 void test219()
3576 {
3577   mixin T219!(int); // using a named mixin here fixes it
3578 
3579   pragma(msg, T219!(int).C.mangleof);
3580   pragma(msg, C.mangleof); // incorrectly outputs the same as above
3581 
3582   assert(T219!(int).C.classinfo !is C.classinfo); // fails
3583   assert(T219!(int).C.mangleof != C.mangleof); // fails
3584 }
3585 
3586 
3587 /***************************************************/
3588 // https://issues.dlang.org/show_bug.cgi?id=2206
3589 
3590 class D220 {}
3591 
3592 template T220(U) {
3593   class C { this() { } }
3594 }
3595 
3596 void test220()
3597 {
3598   mixin T220!(int);
3599 
3600   // all print 8
3601 //  writeln(T220!(int).C.classinfo.initializer.length);
3602 //  writeln(C.classinfo.initializer.length);
3603 //  writeln(D220.classinfo.initializer.length);
3604 
3605   auto c = new C; // segfault in _d_newclass
3606 }
3607 
3608 /***************************************************/
3609 
3610 const struct S5110
3611 {
3612     static int value;
3613 }
3614 
3615 static assert(is(typeof(S5110.value) == int));
3616 
3617 /***************************************************/
3618 
3619 class C5110
3620 {
3621  override:
3622     string toString() { return ""; }
3623 
3624     class Nested
3625     {
3626         void gun() {}
3627     }
3628 }
3629 
3630 /***************************************************/
3631 
3632 immutable class Bug5504
3633 {
3634     void foo(T)(T a) {}
3635     template xx(X) {
3636         void hoo(T)(T a) {}
3637     }
3638 }
3639 
3640 shared class Bug5504b
3641 {
3642     void foo(T)(T a) {}
3643     template xx(X) {
3644         void hoo(T)(T a) {}
3645     }
3646 }
3647 
3648 void test5504()
3649 {
3650     immutable Bug5504 c;
3651     c.foo(10);
3652     c.xx!(int).hoo(10);
3653     shared Bug5504b d;
3654     d.foo(10);
3655     d.xx!(int).hoo(10);
3656 }
3657 
3658 /***************************************************/
3659 
3660 void bug5105() // compilation test -- don't need to run
3661 {
3662     auto c = new shared(C5105);
3663     c.foo(10);
3664 }
3665 
3666 synchronized shared class C5105
3667 {
3668     void foo(T)(T a) {}
3669 }
3670 
3671 /***************************************************/
3672 // https://issues.dlang.org/show_bug.cgi?id=5145
3673 
3674 interface I221{
3675     void bla();
3676 }
3677 
3678 interface J221
3679 {
3680     I221 sync ();
3681 }
3682 
3683 class A221 : B221
3684 {
3685     final override I221 sync()
3686     in { assert( valid ); }
3687     do
3688     {
3689         return null;
3690     }
3691 }
3692 
3693 class B221 : J221
3694 {
3695     override I221 sync()
3696     in { assert( valid ); }
3697     do
3698     {
3699         return null;
3700     }
3701 
3702     final bool valid()
3703     {
3704         return true;
3705     }
3706 }
3707 
3708 /***************************************************/
3709 
3710 template Bug3276(bool B) {
3711    static if (B)
3712       alias Bug3276!(false) Bug3276;
3713    else
3714        alias double Bug3276;
3715 }
3716 
3717 template Bug3276_b(alias W) {
3718     alias W!(true) Bug3276_b;
3719 }
3720 
3721 alias Bug3276_b!(Bug3276) Bug3276_c;
3722 
3723 /***************************************************/
3724 // https://issues.dlang.org/show_bug.cgi?id=5294
3725 
3726 void foo222(int) {}
3727 
3728 void test222()
3729 {
3730     int count;
3731     for (int i = 0; i < 2; i++) {
3732         count++;
3733         foo222(i * 5 - 6); // comment this out and it makes 2 loops
3734     }
3735     printf("%d\n", count); // compile with -O and it prints 1
3736     assert(count == 2);
3737 }
3738 
3739 /***************************************************/
3740 
3741 void foo223(long x,long a,long b,long c,long d,long e,long f)
3742 {
3743     assert(x == 0x123456789ABCDEF0);
3744 }
3745 
3746 void test223()
3747 {
3748     foo223(0x123456789ABCDEF0,2,3,4,5,6,7);
3749 }
3750 
3751 /***************************************************/
3752 // https://issues.dlang.org/show_bug.cgi?id=4379
3753 
3754 template BigTuple(U...) {
3755     alias U BigTuple;
3756 }
3757 
3758 alias
3759 BigTuple!(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
3760 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
3761 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
3762 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
3763 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
3764 1,1,1,1,1,1) Tuple4379;
3765 
3766 void test224()
3767 {
3768     foreach(x; Tuple4379) {    }
3769 }
3770 
3771 /***************************************************/
3772 // https://issues.dlang.org/show_bug.cgi?id=3681
3773 
3774 public final class A3681 {
3775     private this() {
3776         int i =0;
3777         int j = i + 1;
3778  i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59;
3779  i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59;
3780  i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59;
3781  i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59;
3782  i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59;
3783  i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59;
3784  i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59;
3785  i = j * 15; j = i * 59; i = j * 15; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15;
3786  j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15;
3787  j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15;
3788  j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15;
3789  j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15;
3790  j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15;
3791  j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15;
3792  j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15;
3793  j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15;
3794  j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15;
3795  j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15;
3796  j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15;
3797  j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15;
3798  j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15;
3799  j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15;
3800  j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15;
3801  j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15;
3802  j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15;
3803  j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15;
3804  j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15;
3805  j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15;
3806  j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15;
3807  j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15;
3808  j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15;
3809  j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15;
3810  j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15;
3811  j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; j = i * 59; i = j * 15; j = i * 59;
3812  i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59;
3813  i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59; i = j * 15; j = i * 59;
3814     }
3815 }
3816 
3817 /***************************************************/
3818 
3819 int bug4389()
3820 {
3821     string s;
3822     dchar c = '\u2348';
3823     s ~= c;
3824     assert(s.length==3);
3825     dchar d = 'D';
3826     s ~= d;
3827     assert(s.length==4);
3828     s = "";
3829     s ~= c;
3830     assert(s.length==3);
3831     s ~= d;
3832     assert(s.length==4);
3833     string z;
3834     wchar w = '\u0300';
3835     z ~= w;
3836     assert(z.length==2);
3837     z = "";
3838     z ~= w;
3839     assert(z.length==2);
3840     return 1;
3841 }
3842 
3843 static assert(bug4389());
3844 
3845 // ICE(constfold.c)
3846 int ice4389()
3847 {
3848     string s;
3849     dchar c = '\u2348';
3850     s ~= c;
3851     s = s ~ "xxx";
3852    return 1;
3853 }
3854 
3855 static assert(ice4389());
3856 
3857 // ICE(expression.c)
3858 string ice4390()
3859 {
3860     string s;
3861     dchar c = '`';
3862     s ~= c;
3863     s ~= c;
3864    return s;
3865 }
3866 
3867 static assert(mixin(ice4390()) == ``);
3868 static assert(mixin(ice4390()) == ``);
3869 
3870 /***************************************************/
3871 // https://issues.dlang.org/show_bug.cgi?id=190
3872 
3873 alias int avocado;
3874 void eat(avocado x225 = .x225);
3875 avocado x225;
3876 
3877 void test225()
3878 {
3879 }
3880 
3881 /***************************************************/
3882 // https://issues.dlang.org/show_bug.cgi?id=5534
3883 
3884 void doStuff(byte start, byte end, uint increment = 1U) {
3885    auto output = new byte[3];
3886 
3887     size_t count = 0;
3888     for(byte i = start; i < end; i += increment) {
3889         output[count++] = i;
3890     }
3891 }
3892 
3893 void test226()  {
3894     doStuff(0, 3);
3895 }
3896 
3897 /***************************************************/
3898 // https://issues.dlang.org/show_bug.cgi?id=5536
3899 
3900 void test227()
3901 {
3902   int[] as = [111, 666];
3903   as ~= as[$ - 2];
3904   assert(as.length == 3);
3905   assert(as[2] == 111);
3906 }
3907 
3908 /***************************************************/
3909 // https://issues.dlang.org/show_bug.cgi?id=4017
3910 
3911 struct _A
3912 {
3913    uint data;
3914 }
3915 
3916 const A_SIZE =   (A4017.sizeof);
3917 
3918 alias _A A4017;
3919 
3920 /***************************************************/
3921 // https://issues.dlang.org/show_bug.cgi?id=5455
3922 
3923 void thrw(Data *s) {
3924     throw new Exception("xxx");
3925 }
3926 
3927 struct Data {
3928     Rapper *w;
3929     uint n, m;
3930 }
3931 
3932 struct Rapper {
3933     ubyte * dat;
3934     ubyte[] con() {
3935         return dat[0..1];
3936     }
3937 }
3938 
3939 uint jaz(ubyte[] data) {
3940     return cast(uint)data.length;
3941 }
3942 
3943 struct Resp {
3944     void set(Data *data, string[] soup) {
3945         switch(soup[0]) {
3946             default:
3947         }
3948         uint[] f = [jaz(data.w ? data.w.con[data.n ..data.m] : null), data.m - data.n];
3949         thrw(data);
3950     }
3951 }
3952 
3953 /**************************************/
3954 // https://issues.dlang.org/show_bug.cgi?id=5571
3955 
3956 void test228() {
3957     auto b = new bool;
3958     printf("%p\n", b);
3959     *b = false;
3960 }
3961 
3962 /***************************************************/
3963 // https://issues.dlang.org/show_bug.cgi?id=5572
3964 
3965 void doSynchronized() {
3966     printf("In doSynchronized() 1:  %p\n", cast(void*) global229);
3967     synchronized {
3968         printf("In doSynchronized() 2:  %p\n", cast(void*) global229);
3969     }
3970 }
3971 
3972 __gshared Object global229;
3973 
3974 void test229() {
3975     auto local = new Object;
3976     global229 = local;
3977 
3978     printf("In main() 1:  %p\t%p\n",
3979         cast(void*) global229, cast(void*) local);
3980     doSynchronized();
3981     printf("In main() 1:  %p\t%p\n",
3982         cast(void*) global229, cast(void*) local);
3983 
3984     assert(cast(void*) global229 == cast(void*) local);
3985 }
3986 
3987 /***************************************************/
3988 
3989 static immutable real[14] negtab =
3990     [ 1e-4096L,1e-2048L,1e-1024L,1e-512L,1e-256L,1e-128L,1e-64L,1e-32L,
3991             1e-16L,1e-8L,1e-4L,1e-2L,1e-1L,1.0L ];
3992 static immutable real[13] postab =
3993     [ 1e+4096L,1e+2048L,1e+1024L,1e+512L,1e+256L,1e+128L,1e+64L,1e+32L,
3994             1e+16L,1e+8L,1e+4L,1e+2L,1e+1L ];
3995 
3996 float parse(ref string p)
3997 {
3998     printf("test1\n");
3999 
4000     real ldval = 0.0;
4001     int exp = 0;
4002     long msdec = 0;
4003 
4004     msdec = 123;
4005     exp = 2;
4006 
4007     ldval = msdec;
4008     printf("ldval = %Lg\n", ldval);
4009     if (ldval)
4010     {
4011         uint u = 0;
4012         int pow = 4096;
4013 
4014         while (exp > 0)
4015         {
4016             while (exp >= pow)
4017             {
4018                 ldval *= postab[u];
4019                 exp -= pow;
4020             }
4021             pow >>= 1;
4022             u++;
4023         }
4024         while (exp < 0)
4025         {
4026             while (exp <= -pow)
4027             {
4028                 ldval *= negtab[u];
4029                 exp += pow;
4030             }
4031             pow >>= 1;
4032             u++;
4033         }
4034     }
4035     return ldval;
4036 }
4037 
4038 void test230()
4039 {
4040     float f;
4041     string s = "123e+2";
4042     f = parse( s );
4043     //printf("f = %g\n", f);
4044     assert( f == 123e+2f );
4045 }
4046 
4047 /***************************************************/
4048 
4049 class Bug4033 {}
4050 
4051 class Template4033(T) {
4052     static assert(is(T : Bug4033));
4053 }
4054 
4055 alias Template4033!(Z4033) Bla;
4056 
4057 class Z4033 : Bug4033 { }
4058 
4059 /***************************************************/
4060 
4061 struct Bug4322 {
4062     int[1] a = void;
4063 }
4064 
4065 void bug4322() {
4066     Bug4322 f = Bug4322();
4067     Bug4322 g = Bug4322.init;
4068 }
4069 
4070 /***************************************************/
4071 
4072 bool bug5672(long v)
4073 {
4074     return  (v & 1) == 1;
4075     return  (v & 1) == 1;
4076 }
4077 
4078 /***************************************************/
4079 
4080 void bug5717()
4081 {
4082     string s, s2;
4083     s = "Привет";
4084     for (int i=0; i<s.length; i++)
4085         s2 ~= s[i];
4086     assert(s == s2);
4087 }
4088 
4089 /***************************************************/
4090 // https://issues.dlang.org/show_bug.cgi?id=3086
4091 
4092 class X231 {
4093     void a() {}
4094     void b(int z, short c) {}
4095     void c(int z, short d) {}
4096 }
4097 
4098 void test231() {
4099     auto z = new X231();
4100     TypeInfo a = typeid(typeof(&z.a));
4101     TypeInfo b = typeid(typeof(&z.b));
4102     TypeInfo c = typeid(typeof(&z.c));
4103 
4104     assert(a !is b, "1");
4105     assert(a != b, "2");
4106     assert(b == c, "3");
4107 }
4108 
4109 /***************************************************/
4110 // https://issues.dlang.org/show_bug.cgi?id=4140
4111 
4112 const A232 = [1,2,3];
4113 const B232 = A232[1..A232.length];
4114 const C232 = A232[1..$];
4115 
4116 void test232()
4117 {
4118     assert(A232[0] == 1);
4119     assert(A232[1] == 2);
4120     assert(A232[2] == 3);
4121     assert(B232[0] == 2);
4122     assert(B232[1] == 3);
4123     assert(C232[0] == 2);
4124     assert(C232[1] == 3);
4125 }
4126 
4127 /***************************************************/
4128 // https://issues.dlang.org/show_bug.cgi?id=1389
4129 
4130 void test233()
4131 {
4132     int a;
4133     mixin("a") = 666;
4134 }
4135 
4136 /***************************************************/
4137 // https://issues.dlang.org/show_bug.cgi?id=5735
4138 
4139 struct A234 {}
4140 
4141 void foo234(bool cond){}
4142 
4143 void test234()
4144 {
4145     A234 a;
4146     int i;
4147 
4148     static assert(!__traits(compiles, assert(a)));      // type A does not have a boolean value
4149     static assert(!__traits(compiles, assert(i || a))); // type A does not have a boolean value
4150     static assert(!__traits(compiles, assert(0 || a))); // OK
4151 
4152 //    if(a) {}        // type A does not have a boolean value
4153 //    if(i || a) {}   // type A does not have a boolean value
4154 //    if(0 || a) {}   // type A does not have a boolean value
4155 
4156     static assert(!__traits(compiles, foo234(a)));         // cannot implicitly convert type A to bool
4157     static assert(!__traits(compiles, foo234(i || a)));    // OK
4158     static assert(!__traits(compiles, foo234(0 || a)));    // OK
4159 }
4160 
4161 
4162 /***************************************************/
4163 
4164 int space() { return 4001; }
4165 
4166 void oddity4001()
4167 {
4168     const int bowie = space();
4169     static assert(space() == 4001); // OK
4170     static assert(bowie == 4001);   // doesn't compile
4171 }
4172 
4173 /***************************************************/
4174 // https://issues.dlang.org/show_bug.cgi?id=3809
4175 
4176 int bug3809()
4177 {
4178     static int a = 0;
4179     return a;
4180 }
4181 
4182 struct BUG3809
4183 {
4184     int xx;
4185 }
4186 
4187 void bug3809b()
4188 {
4189     BUG3809 b = { bug3809() };
4190 }
4191 
4192 /***************************************************/
4193 //
4194 
4195 void bug6184()
4196 {
4197     bool cmp(ref int[3] a, ref int[3] b)
4198     {
4199         return a[] is b[];
4200     }
4201 
4202     static struct Ary
4203     {
4204         int[3] ary;
4205     }
4206 
4207     auto a = new Ary;
4208     auto b = new Ary;
4209     assert(!cmp(a.ary, b.ary));
4210     b = a;
4211     assert(cmp(a.ary, b.ary));
4212 
4213     // change high bit of ary address
4214     *(cast(size_t*)&b) ^= (1UL << (size_t.sizeof * 4));
4215     assert(!cmp(a.ary, b.ary));
4216 }
4217 
4218 /***************************************************/
4219 // https://issues.dlang.org/show_bug.cgi?id=6229
4220 
4221 int test6229()
4222 {
4223   {
4224     ubyte a = 2;
4225     ubyte b = 4;
4226     b += a;
4227   }
4228 
4229     char a = 2;
4230     char b = 4;
4231     b += a;
4232 
4233     wchar c = 2;
4234     wchar d = 4;
4235     c /= d;
4236 
4237     return b;
4238 }
4239 
4240 /***************************************************/
4241 // XMMBug
4242 
4243 class XMMPainter
4244 {
4245   float call()
4246   {
4247     return sumFloats(0.0f, 0.0f);
4248   }
4249 
4250   static float sumFloats(float a, float b)
4251   {
4252     return a + b;
4253   }
4254 }
4255 
4256 void test6270()
4257 {
4258   auto painter = new XMMPainter;
4259   assert(XMMPainter.sumFloats(20, painter.call()) == 20.0f);
4260   auto dg = () { return XMMPainter.sumFloats(0.0f, 0.0f); };
4261   assert(XMMPainter.sumFloats(20, dg()) == 20.0f);
4262 }
4263 
4264 /***************************************************/
4265 
4266 void testrolror(int shift)
4267 {
4268     uint a = 7;
4269     uint r;
4270     r = (a >> shift) | (a << (int.sizeof * 8 - shift));
4271     assert(r == 0x8000_0003);
4272     r = (r << shift) | (r >> (int.sizeof * 8 - shift));
4273     assert(r == 7);
4274 }
4275 
4276 void test236()
4277 {
4278     testrolror(1);
4279 }
4280 
4281 
4282 /***************************************************/
4283 // https://issues.dlang.org/show_bug.cgi?id=4460
4284 
4285 void test237()
4286 {
4287     foreach (s, i; [ "a":1, "b":2 ])
4288     {
4289         //writeln(s, i);
4290     }
4291 }
4292 
4293 
4294 /***************************************************/
4295 
4296 void foo238(long a, long b)
4297 {
4298   while (1)             // prevent inlining
4299   {
4300     long x = a / b;
4301     long y = a % b;
4302     assert(x == 3);
4303     assert(y == 1);
4304     break;
4305   }
4306 }
4307 
4308 void test238()
4309 {
4310     long a, b;
4311     a = 10;
4312     b = 3;
4313     long x = a / b;
4314     long y = a % b;     // evaluate at compile time
4315     assert(x == 3);
4316     assert(y == 1);
4317 
4318     foo238(a, b);
4319 }
4320 
4321 /***************************************************/
4322 // https://issues.dlang.org/show_bug.cgi?id=5239
4323 
4324 struct S239 { int x; }
4325 
4326 int test239()
4327 {
4328    S239[4] w = void;
4329    w[$-2].x = 217;
4330    return w[2].x;
4331 }
4332 
4333 
4334 /***************************************************/
4335 
4336 void enforce6506b(bool condition, void delegate() m) {
4337     assert(!condition);
4338 }
4339 void toImpl6506b(int value) {
4340     void f(){}
4341     enforce6506b(value >= 0, &f);
4342 }
4343 void test6506() {
4344     toImpl6506b(-112345);
4345 }
4346 
4347 /***************************************************/
4348 // https://issues.dlang.org/show_bug.cgi?id=6505
4349 
4350 double foo240() {
4351     return 1.0;
4352 }
4353 
4354 void test240() {
4355     double a = void;
4356     double b = void;
4357     double x = void;
4358     version (D_SIMD)
4359     {
4360 //	assert((cast(size_t)&a & 7) == 0);
4361 //	assert((cast(size_t)&b & 7) == 0);
4362 //	assert((cast(size_t)&x & 7) == 0);
4363     }
4364     a = foo240();
4365     b = foo240();
4366     x = a*a + a*a + a*a + a*a + a*a + a*a + a*a +
4367                a*b + a*b;
4368     assert(x > 0);
4369 }
4370 
4371 /***************************************************/
4372 // https://issues.dlang.org/show_bug.cgi?id=6563
4373 
4374 int foo6563(float a, float b, float c, float d, float e, float f, float g, float h)
4375 {
4376     assert(a == 1);
4377     return 0; // return something to prevent folding
4378 }
4379 
4380 void test6563()
4381 {
4382     auto res = foo6563(1, 1, 1, 1, 1, 1, 1, 1);
4383 }
4384 
4385 /***************************************************/
4386 
4387 ubyte foo241(ubyte[] data)
4388 {
4389     ubyte a, b, c, d;
4390 
4391     a = data[0];
4392     b = data[1];
4393     c = data[2];
4394     d = data[3];
4395 
4396     c <<= 1;
4397     if (c & 0x80)
4398         c >>= 1;
4399     d <<= 1;
4400     if (d & 0x80)
4401         d >>= 1;
4402 
4403     return d;
4404 }
4405 
4406 void test241()
4407 {
4408     ubyte[4] data;
4409     data[3] = 0x40;
4410     assert(foo241(data[]) == 0x40);
4411     data[3] = 0x20;
4412     assert(foo241(data[]) == 0x40);
4413 }
4414 
4415 /***************************************************/
4416 
4417 struct Foo6665
4418 {
4419     double[2][2] dat;
4420 
4421     double foo(size_t i, size_t j)
4422     {
4423         return dat[i][j] = 0;
4424     }
4425 }
4426 
4427 void test6665()
4428 {
4429     Foo6665 a;
4430 }
4431 
4432 /***************************************************/
4433 
4434 double entropy(double[] probs) {
4435     double result = 0;
4436     foreach (p; probs) {
4437         if (!p) continue;
4438         result -= p;
4439     }
4440     return result;
4441 }
4442 
4443 /***************************************************/
4444 
4445 long b5364(long bmax){
4446     if(true){
4447     }
4448     if(bmax >= 0) bmax = -1;
4449     return bmax;
4450 }
4451 
4452 void test5364()
4453 {
4454     assert(b5364(0) == -1L);
4455 }
4456 
4457 
4458 /***************************************************/
4459 
4460 struct FPoint {
4461   float x, y;
4462 }
4463 
4464 void constructBezier(FPoint p0, FPoint p1, FPoint p2, ref FPoint[3] quad) {
4465   quad[0] = p0;
4466   quad[1] = FPoint(p1.x, p1.y);
4467   quad[$-1] = p2;
4468 }
4469 
4470 void test6189() {
4471   auto p0 = FPoint(0, 0);
4472   auto p1 = FPoint(1, 1);
4473   auto p2 = FPoint(2, 2);
4474 
4475   // avoid inline of call
4476   FPoint[3] quad;
4477   auto f = &constructBezier;
4478   f(p0, p1, p2, quad);
4479 
4480   assert(quad == [p0, p1, p2]);
4481 }
4482 
4483 /***************************************************/
4484 // https://issues.dlang.org/show_bug.cgi?id=6997
4485 
4486 long fun6997(long a,long b,long c)
4487 {
4488     return a < b ? a < c ? a : b < c ? b : c : b;
4489 }
4490 
4491 long baz6997(long a, long b)
4492 {
4493     bool s = (a<0) != (b<0);
4494     a = a > 0 ? a : -a;
4495     return s ? a : a;
4496 }
4497 
4498 struct S6997
4499 {
4500     ulong bar, qux;
4501     bool c;
4502 
4503     S6997 foo()
4504     {
4505         if(!c)
4506         {
4507             long a = baz6997(bar, 0),
4508                 b = baz6997(bar, 0),
4509                 c = baz6997(bar, 0);
4510             return S6997(fun6997(a,b,c), fun6997(a,b,c));
4511         }
4512         return S6997();
4513     }
4514 }
4515 
4516 void test6997()
4517 {
4518     auto x = S6997().foo();
4519 }
4520 
4521 
4522 /***************************************************/
4523 
4524 ubyte foo7026(uint n) {
4525   ubyte[5] buf = void;
4526   ubyte wsize;
4527 
4528   while (true) {
4529     if ((n & ~0x7F) == 0) {
4530       buf[wsize++] = cast(ubyte)n;
4531       break;
4532     } else {
4533       buf[wsize++] = cast(ubyte)((n & 0x7F) | 0x80);
4534       n >>= 7;
4535     }
4536   }
4537 
4538   printf("%hhu\n", wsize);
4539   return buf[0];
4540 }
4541 
4542 void test7026() {
4543     if (foo7026(3) != 3)
4544         assert(0);
4545 }
4546 
4547 
4548 /***************************************************/
4549 
4550 void test6354()
4551 {
4552     foreach(j; 0 .. 2)
4553     {
4554         scope(failure) int i = 0;
4555 
4556         ushort left = 0xffU;
4557         left <<= (ushort.sizeof - 1) * 8;
4558 
4559         assert((((left & 0xff00U) >> 8) | ((left & 0x00ffU) << 8)) == 0xffu);
4560     }
4561 }
4562 
4563 /***************************************************/
4564 
4565 struct S7072
4566 {
4567     this(A)(A args) { }
4568 }
4569 
4570 void test7072() {
4571    auto s = S7072( null );
4572 }
4573 
4574 /***************************************************/
4575 
4576 struct Point6881
4577 {
4578     float _x, _y;
4579 
4580     void rotateCCW()
4581     {
4582         float tmp = -_x;
4583         _x = _y;
4584         _y = tmp;
4585     }
4586 }
4587 
4588 /***************************************************/
4589 // https://issues.dlang.org/show_bug.cgi?id=7212
4590 void foo7212(scope int delegate(int a) dg)
4591 {
4592 }
4593 
4594 void foo7212(bool a)
4595 {
4596 }
4597 
4598 void test7212()
4599 {
4600     foo7212((int a) => a);
4601 }
4602 
4603 /***************************************************/
4604 
4605 void test242()
4606 {
4607     foreach(v; long.max / 8 .. long.max / 8 + 1)
4608     {
4609         immutable long t1 = v;
4610         long t2 = t1 + t1;
4611         t2 *= 1L << 1;
4612         assert(t2 > long.max / 4);
4613     }
4614 }
4615 
4616 /***************************************************/
4617 // https://issues.dlang.org/show_bug.cgi?id=7290
4618 
4619 void foo7290a(alias dg)()
4620 {
4621     assert(dg(5) == 7);
4622 }
4623 
4624 void foo7290b(scope int delegate(int a) dg)
4625 {
4626     assert(dg(5) == 7);
4627 }
4628 
4629 void foo7290c(int delegate(int a) dg)
4630 {
4631     assert(dg(5) == 7);
4632 }
4633 
4634 void test7290()
4635 {
4636     int add = 2;
4637     scope dg = (int a) => a + add;
4638 
4639     // This will break with -preview=dip1000 because a closure will no longer be allocated
4640     assert(GC.addrOf(dg.ptr) == null);
4641 
4642     foo7290a!dg();
4643     foo7290b(dg);
4644     foo7290c(dg); // this will fail with -preview=dip1000 and @safe because a scope delegate gets
4645                   // assigned to @system delegate, but no closure was allocated
4646 }
4647 
4648 /***************************************************/
4649 
4650 void test7367()
4651 {
4652     char a = '\x00';
4653     char b = '\xFF';
4654     assert(a < b);
4655 }
4656 
4657 /***************************************************/
4658 // https://issues.dlang.org/show_bug.cgi?id=7375
4659 
4660 class A7375 {}
4661 class B7375(int i) : A7375 {}
4662 class C7375(int i) : B7375!i {}
4663 
4664 template DerivedAlias(int i)
4665 {
4666     alias B7375!i DerivedAlias;
4667 }
4668 
4669 alias DerivedAlias!22 X7375;
4670 
4671 void test7375()
4672 {
4673     A7375 foo = new C7375!11();
4674     assert(cast(B7375!22)foo is null);
4675 }
4676 
4677 /***************************************************/
4678 
4679 void test6504()
4680 {
4681     for (int i=0; i<3; ++i)
4682     {
4683 /+
4684         char[] x2 = "xxx" ~ ['c'];
4685         if (i == 0)
4686             assert(x2[1] == 'x');
4687         x2[1] = 'q';
4688 +/
4689     }
4690 }
4691 
4692 /***************************************************/
4693 
4694 struct S7424a
4695 {
4696     @property inout(int) g()() inout { return 7424; }
4697     void test1()
4698     {
4699         int f = g;
4700         assert(f == 7424);
4701         assert(g == 7424);
4702     }
4703     void test2() const
4704     {
4705         int f = g;
4706         assert(f == 7424);
4707         assert(g == 7424);
4708     }
4709     void test3() immutable
4710     {
4711         int f = g;
4712         assert(f == 7424);
4713         assert(g == 7424);
4714     }
4715 }
4716 struct S7425
4717 {
4718     inout(T) g(T)(T x) inout
4719     {
4720         return x;
4721     }
4722     void test1()
4723     {
4724         int f = g(2);
4725         assert(f == 2);
4726     }
4727     void test2() const
4728     {
4729         double y = g(4.5);
4730         assert(y == 4.5);
4731     }
4732 }
4733 void test7424()
4734 {
4735     S7424a s1;
4736     s1.test1();
4737     s1.test2();
4738 
4739     immutable(S7424a) s2;
4740     s2.test2();
4741     s2.test3();
4742 
4743     const(S7424a) s3;
4744     s3.test2();
4745 
4746     S7425 s4;
4747     s4.test1();
4748     s4.test2();
4749 }
4750 
4751 /***************************************************/
4752 
4753 struct Logger {
4754     static bool info()() {
4755         return false;
4756     }
4757 }
4758 
4759 void test7422() {
4760     if (Logger.info()) {
4761     }
4762 }
4763 
4764 /***************************************************/
4765 
4766 struct S7502
4767 {
4768     int[0x1000] arr;
4769 }
4770 
4771 S7502 s7502;
4772 
4773 void test7502()
4774 {
4775     s7502 = s7502.init;
4776 }
4777 
4778 /***************************************************/
4779 
4780 void nextis(void delegate() dg = {}) {}
4781 
4782 void test4820() {
4783     nextis();
4784 }
4785 
4786 /***************************************************/
4787 
4788 void test4820_2() {
4789 
4790 void nextis(void delegate() dg = {}) {}
4791     nextis();
4792 }
4793 
4794 /***************************************************/
4795 
4796 template T3509(bool b) { static assert (b); }
4797 
4798 template Mix3509() { void f() {} }
4799 
4800 class C3509 {
4801     alias T3509!(is(typeof(M.f))) U;
4802     mixin Mix3509!() M;
4803 }
4804 
4805 /***************************************************/
4806 
4807 struct S3510(int x) {}
4808 
4809 template Mix3510() { Sa s; }
4810 
4811 class C3510 {
4812     mixin Mix3510!();
4813     alias S3510!(0) Sa;
4814 }
4815 
4816 /***************************************************/
4817 
4818 struct Array243(T) if (is(T == bool))
4819 {
4820     struct Range
4821     {
4822         Array243!bool _outer;
4823         ulong _a, _b, _c;
4824         ulong _d;
4825     }
4826 
4827     Range opSlice()
4828     {
4829         return Range(this, 0, 3);
4830     }
4831 
4832 }
4833 
4834 
4835 void test243() {
4836     Array243!bool a;
4837 }
4838 
4839 /***************************************************/
4840 // https://issues.dlang.org/show_bug.cgi?id=7742
4841 
4842 struct Foo7742 {
4843     static immutable f = Foo7742(1, 2);
4844     int x, y;
4845 }
4846 
4847 struct Bar7742 {
4848     int x, y;
4849     static immutable f = Bar7742(1, 2);
4850 }
4851 
4852 void test7742()
4853 {
4854     assert(Foo7742.f.x == 1);
4855     assert(Foo7742.f.y == 2);
4856 
4857     assert(Bar7742.f.x == 1);
4858     assert(Bar7742.f.y == 2);
4859 }
4860 
4861 /***************************************************/
4862 // https://issues.dlang.org/show_bug.cgi?id=7807
4863 
4864 interface Interface7807
4865 {
4866     Interface7807 getNext();
4867     const(Interface7807) getNext() const;
4868 }
4869 
4870 class Implementation7807 : Interface7807
4871 {
4872     Implementation7807 getNext()
4873     {
4874         return this;
4875     }
4876 
4877     const(Implementation7807) getNext() const
4878     {
4879         return null;
4880     }
4881 }
4882 
4883 void test7807()
4884 {
4885     auto mc = new Implementation7807();
4886     assert(mc.getNext() is mc);
4887     Interface7807 mi = mc;
4888     assert(mi.getNext() is mi);
4889 
4890     auto cc = new const(Implementation7807)();
4891     assert(cc.getNext() is null);
4892     const(Interface7807) ci = cc;
4893     assert(ci.getNext() is null);
4894 }
4895 
4896 /***************************************************/
4897 // https://issues.dlang.org/show_bug.cgi?id=7815
4898 
4899 enum Closure {
4900     Matrix
4901 }
4902 
4903 struct BasicMatrix {
4904     mixin Operand!( Closure.Matrix );
4905 }
4906 
4907 template Operand( Closure closure_ ) {
4908     alias closure_ closure;
4909 }
4910 
4911 struct Expression( string op_, Lhs, Rhs = void ) {
4912     enum lhsClosure = closureOf!Lhs;
4913 }
4914 
4915 template closureOf( T ) {
4916     enum closureOf = T.closure;
4917 }
4918 
4919 alias Expression!("+", BasicMatrix) Foo7815;
4920 
4921 /***************************************************/
4922 
4923 struct Test244 {
4924     static immutable c = Test244();
4925     static if( true ){}
4926 }
4927 
4928 /***************************************************/
4929 
4930 int noswap245(ubyte *data)
4931 {
4932     version (LittleEndian)
4933         return
4934             (data[0]<<  0) |
4935             (data[1]<<  8) |
4936             (data[2]<< 16) |
4937             (data[3]<< 24);
4938     version (BigEndian)
4939         return
4940             (data[0]<< 24) |
4941             (data[1]<< 16) |
4942             (data[2]<<  8) |
4943             (data[3]<<  0);
4944 
4945 }
4946 
4947 int bswap245(ubyte *data)
4948 {
4949     version (LittleEndian)
4950         return
4951             (data[0]<< 24) |
4952             (data[1]<< 16) |
4953             (data[2]<<  8) |
4954             (data[3]<<  0);
4955     version (BigEndian)
4956         return
4957             (data[0]<<  0) |
4958             (data[1]<<  8) |
4959             (data[2]<< 16) |
4960             (data[3]<< 24);
4961 }
4962 
4963 void test245()
4964 {
4965     int x1 = 0x01234567;
4966     x1 = noswap245(cast(ubyte *)&x1);
4967     assert(x1 == 0x01234567);
4968     x1 = bswap245(cast(ubyte *)&x1);
4969     assert(x1 == 0x67452301);
4970 }
4971 
4972 /***************************************************/
4973 
4974 mixin template mix7974()
4975 {
4976     uint _x;
4977 }
4978 
4979 struct Foo7974
4980 {
4981     static immutable Foo7974 fa = Foo7974(0);
4982 
4983     this(uint x)
4984     {
4985         _x = x;
4986     }
4987 
4988     mixin mix7974!();
4989 }
4990 
4991 /***************************************************/
4992 // https://issues.dlang.org/show_bug.cgi?id=4155
4993 
4994 
4995 float getnanf() { return float.nan; }
4996 double getnand() { return double.nan; }
4997 real getnanr() { return real.nan; }
4998 
4999 void test4155()
5000 {
5001     assert(getnanf() != 0);
5002     assert(getnand() != 0);
5003     assert(getnanr() != 0);
5004 }
5005 
5006 /***************************************************/
5007 // https://issues.dlang.org/show_bug.cgi?id=7911
5008 
5009 struct Klass7911
5010 {
5011     double value;
5012 
5013     //static const Klass zero; // Does not trigger bug!
5014     static const Klass7911 zero = {0}; // Bug trigger #1
5015 
5016     static if (true) // Bug trigger #2
5017         static if (true)
5018             Klass7911 foo() { return Klass7911(); }
5019 }
5020 
5021 void test7911()
5022 {
5023     auto a = Klass7911().foo();
5024 }
5025 
5026 /***************************************************/
5027 // https://issues.dlang.org/show_bug.cgi?id=8429
5028 
5029 static if(true)
5030     version = Foo8429;
5031 static if(true)
5032     version(Foo8429) {}
5033 
5034 /***************************************************/
5035 // https://issues.dlang.org/show_bug.cgi?id=8069
5036 
5037 interface I8069
5038 {
5039     void f();
5040 }
5041 struct A8069
5042 {
5043     final class B8069 : I8069
5044     {
5045         A8069 a;
5046         void f() {}
5047     }
5048 }
5049 
5050 /***************************************************/
5051 // https://issues.dlang.org/show_bug.cgi?id=8095
5052 
5053 void bug8095(int p0, int *p1, int z, int edx, int *p4, int p5)
5054 {
5055     int x = z / 3;
5056     if (z) {
5057         int c = p5 + *p1 + p0; // *p1 segfaults -- it does *z !!
5058         if ( z / 5 )
5059             c = 1;
5060         *p4 = c;
5061         x = c;
5062     }
5063     void never_used() {
5064         ++x;
5065         int * unused = p1; // kills p4 somehow
5066     }
5067 }
5068 
5069 void test8095() {
5070     int x, y;
5071     bug8095(0, &x, 1, 0, &y, 0);
5072 }
5073 
5074 /***************************************************/
5075 // https://issues.dlang.org/show_bug.cgi?id=8091
5076 
5077 int solve1(int n) {
5078     int a;
5079     return ((a = n ? (n>=1u) : 1) != 0) ? a : 0;
5080 //    return ((a = !n ? 1 : (n>=1u)) != 0) ? a : 0;
5081 }
5082 
5083 int solve2(int n) {
5084     int a;
5085 //    return ((a = n ? (n>=1u) : 1) != 0) ? a : 0;
5086     return ((a = !n ? 1 : (n>=1u)) != 0) ? a : 0;
5087 }
5088 
5089 void test8091() {
5090     assert(solve1(1) ==  1);
5091     assert(solve2(1) ==  1);
5092 }
5093 
5094 /***************************************************/
5095 
5096 struct IPoint {
5097     int x, y;
5098 }
5099 
5100 void bug6189_2(uint half, IPoint pos, float[4] *pts, uint unused) {
5101     pos.y += half;
5102     float xo = pos.x;
5103     float yo = pos.y;
5104 
5105     (*pts)[0] = xo;
5106     (*pts)[1] = yo;
5107     (*pts)[2] = xo;
5108 }
5109 
5110 void test6189_2()
5111 {
5112     auto pos = IPoint(2, 2);
5113     float[4] pts;
5114     pts[0] = pts[1] = pts[2] = pts[3] = 0;
5115     bug6189_2(0, pos, &pts, 0);
5116 
5117     assert(pts[0] == 2);
5118 }
5119 
5120 /***************************************************/
5121 // https://issues.dlang.org/show_bug.cgi?id=8199
5122 
5123 version (D_InlineAsm_X86_64)
5124 {
5125     version = Check;
5126     enum Align = 0x8;
5127 }
5128 else version (D_InlineAsm_X86)
5129 {
5130     version = Check;
5131     version (OSX)
5132         enum Align = 0xC;
5133 //    version (linux)
5134 //        enum Align = 0xC;
5135 }
5136 
5137 void onFailure()
5138 {
5139     assert(0, "alignment failure");
5140 }
5141 
5142 void checkAlign()
5143 {
5144     version (Check)
5145     {
5146         static if (is(typeof(Align)))
5147         asm
5148         {
5149             naked;
5150             mov EAX, ESP;
5151             and EAX, 0xF;
5152             cmp EAX, Align;
5153             je Lpass;
5154             call onFailure;
5155         Lpass:
5156             ret;
5157         }
5158     }
5159     else
5160         return;
5161 }
5162 
5163 void foo8199()
5164 {
5165 }
5166 
5167 void test8199()
5168 {
5169     try
5170         foo8199();
5171     finally
5172         checkAlign();
5173 }
5174 
5175 /***************************************************/
5176 // https://issues.dlang.org/show_bug.cgi?id=13285
5177 void test13285()
5178 {
5179     static struct S
5180     {
5181         ~this()
5182         {
5183             checkAlign();
5184         }
5185     }
5186     S s; // correct alignment of RSP when calling ~this()
5187     S(); // incorrect alignment
5188 }
5189 
5190 /***************************************************/
5191 
5192 void test246()
5193 {
5194     struct Struct
5195     {
5196         void method() {}
5197     }
5198     auto val = Struct();
5199 }
5200 
5201 /***************************************************/
5202 
5203 double sqrt8454(double d) { return d/2; }
5204 void foo8454(cdouble m) {}
5205 void test8454() {
5206     foo8454(0 - sqrt8454(1.0) * 1i);
5207 }
5208 
5209 /***************************************************/
5210 // https://issues.dlang.org/show_bug.cgi?id=8423
5211 
5212 struct S8423
5213 {
5214     int opCmp(S8423 rhs)
5215     {
5216         return 1;
5217     }
5218 }
5219 
5220 void enforce8423(bool value, string a, string b)
5221 {
5222     if (!value) assert(false);
5223 }
5224 
5225 void test8423()
5226 {
5227     auto a = S8423();
5228     auto b = S8423();
5229     enforce8423(a > b, null, null);
5230 }
5231 
5232 /***************************************************/
5233 class Foo8496
5234 {
5235 public:
5236     void foo(uint value)
5237     {
5238         ubyte size = value < (0x7fU << 0 ) ? 1 :
5239                      value < (0x7fU << 14) ? 2 :
5240                                              3;
5241         printf("%u\n", size);
5242         assert(size == 2);
5243     }
5244 }
5245 
5246 void test8496()
5247 {
5248     Foo8496 f = new Foo8496();
5249     f.foo(1000000);
5250 }
5251 
5252 /***************************************************/
5253 
5254 long foo8840() { return 4; }
5255 
5256 int bar8840(long g) { assert(g == 4); return printf("%llx\n", g); }
5257 
5258 void test8840()
5259 {
5260     long f1 = foo8840();
5261     long f2 = foo8840();
5262 
5263     long f = (f1 < f2 ? f1 : f2);
5264     int len = (f == 0 ? 0 : bar8840(f));
5265 }
5266 
5267 /***************************************************/
5268 
5269 struct S8889
5270 {
5271     real f;
5272     int i;
5273 }
5274 
5275 void test8889()
5276 {
5277 }
5278 
5279 /***************************************************/
5280 
5281 struct S8870
5282 {
5283     float x = 0;
5284     float y = 0;
5285     float z = 0;
5286     float w = 0;
5287 }
5288 
5289 void test8870()
5290 {
5291     S8870 r1 = S8870(1,2,3,4);
5292     S8870 r2 = S8870(5,6,7,8);
5293 
5294     foo8870(r1, r2, false, 1);
5295     bar8870(r1, r2, false, 1);
5296 }
5297 
5298 //extern (C)
5299 void foo8870(S8870 t1, S8870 t2, bool someBool, float finalFloat)
5300 {
5301     printf("t1: %g %g %g %g\n", t1.x, t1.y, t1.z, t1.w);
5302     printf("t2: %g %g %g %g\n", t2.x, t2.y, t2.z, t2.w);
5303     printf("someBool: %d\n", someBool);
5304     printf("finalFloat: %g\n", finalFloat);
5305 
5306     assert(t1.x == 1 && t1.y == 2 && t1.z == 3 && t1.w == 4);
5307     assert(t2.x == 5 && t2.y == 6 && t2.z == 7 && t2.w == 8);
5308     assert(someBool == false);
5309     assert(finalFloat == 1);
5310 }
5311 
5312 extern (C)
5313 void bar8870(S8870 t1, S8870 t2, bool someBool, float finalFloat)
5314 {
5315     printf("t1: %g %g %g %g\n", t1.x, t1.y, t1.z, t1.w);
5316     printf("t2: %g %g %g %g\n", t2.x, t2.y, t2.z, t2.w);
5317     printf("someBool: %d\n", someBool);
5318     printf("finalFloat: %g\n", finalFloat);
5319 
5320     assert(t1.x == 1 && t1.y == 2 && t1.z == 3 && t1.w == 4);
5321     assert(t2.x == 5 && t2.y == 6 && t2.z == 7 && t2.w == 8);
5322     assert(someBool == false);
5323     assert(finalFloat == 1);
5324 }
5325 
5326 /***************************************************/
5327 
5328 int foo9781(int[1] x)
5329 {
5330     return x[0] * x[0];
5331 }
5332 
5333 void test9781()
5334 {
5335     foo9781([7]);
5336 }
5337 
5338 /***************************************************/
5339 
5340 struct S247 { size_t length; size_t ptr; }
5341 
5342 S247 foo247()
5343 {
5344     S247 f;
5345     f.length = 7;
5346     f.ptr = 8;
5347     return f;
5348 }
5349 
5350 void test247()
5351 {
5352     S247 f;
5353     f = foo247();
5354     assert(f.length == 7);
5355     assert(f.ptr == 8);
5356 }
5357 
5358 /***************************************************/
5359 // https://issues.dlang.org/show_bug.cgi?id=8340
5360 
5361 void test8340(){
5362     byte[] ba = [1,2,3,4,5];
5363     short[] sa = [1,2,3,4,5];
5364     int[] ia = [1,2,3,4,5];
5365     long[] la = [1,2,3,4,5];
5366 
5367     ba[2] *= -1;
5368     sa[2] *= -1;
5369     ia[2] *= -1;
5370     la[2] *= -1;
5371 
5372     assert(ba == [1,2,-3,4,5]);
5373     assert(sa == [1,2,-3,4,5]);
5374     assert(ia == [1,2,-3,4,5]);
5375     assert(la == [1,2,-3,4,5]);
5376 }
5377 
5378 /***************************************************/
5379 // https://issues.dlang.org/show_bug.cgi?id=8376
5380 
5381 void test8376() {
5382     int i = 0;
5383     int[2] a;
5384     a[1]=1;
5385     while(!a[0]){
5386         if(a[i]) continue;
5387         a[i] = 1;
5388     }
5389 }
5390 
5391 /***************************************************/
5392 
5393 // Don't call, compile only
5394 void test8987(){
5395     int last = 0;
5396     int count = 0;
5397     int d;
5398 
5399     for (int x = 0; count < 100; x++){
5400         d = 3;
5401 
5402         while (x / d)
5403             d += 2;
5404 
5405         if (x & d) {
5406             last = x;
5407             count++;
5408         }
5409     }
5410 
5411     printf("Last: %d\n", last);
5412 }
5413 
5414 /***************************************************/
5415 // https://issues.dlang.org/show_bug.cgi?id=8796
5416 
5417 int* wrong8796(int* p)
5418 {
5419     *p++ = 1;
5420     return p;
5421 }
5422 
5423 void test8796()
5424 {
5425     int[3] arr;
5426     int* q = arr.ptr;
5427     q = wrong8796(q);
5428     assert(q != arr.ptr);
5429 }
5430 
5431 /***************************************************/
5432 // https://issues.dlang.org/show_bug.cgi?id=9171
5433 
5434 ulong bitcomb9171(ulong v)
5435 {
5436     if(v)
5437     {
5438         ulong result;
5439         if(v & 1)
5440         {
5441             auto r = bitcomb9171(v >> 1);
5442             printf("r=%016llx\n", r);
5443 
5444             auto z = ((r & (r-1) ^ r));
5445             check9171("str", z>>1);
5446 //          printf("z=%016llx\n", z>>1);
5447             return r;
5448         }
5449         else
5450         {
5451             auto fb = v & (v-1) ^ v;
5452             result = (fb >> 1) | (v ^ fb);
5453         }
5454         return result;
5455     }
5456     return 0;
5457 }
5458 
5459 void check9171(const char *s, ulong v)
5460 {
5461     assert(v == 0x80000000);
5462 }
5463 
5464 void test9171()
5465 {
5466     bitcomb9171(0b1110000000000000010000000000000000000000000000000001);
5467 }
5468 
5469 /***************************************************/
5470 // https://issues.dlang.org/show_bug.cgi?id=9248
5471 
5472 void test9248()
5473 {
5474     void*[] a = [cast(void*)1];
5475     void*[] b = [cast(void*)2];
5476     auto c = a ~ b;
5477     assert(c == [cast(void*)1, cast(void*)2]);
5478 }
5479 
5480 /***************************************************/
5481 // https://issues.dlang.org/show_bug.cgi?id=14682
5482 
5483 void test14682a()
5484 {
5485     // operands
5486     int[]       a1;
5487     int[][]     a2;
5488     int[][][]   a3;
5489     int[][][][] a4;
5490 
5491     // results
5492     int[]       r1w =    [];    assert(r1w.length == 0);
5493     int[][]     r2w =    [];    assert(r2w.length == 0);
5494     int[][][]   r3w =    [];    assert(r3w.length == 0);
5495     int[][][][] r4w =    [];    assert(r4w.length == 0);
5496     // ----
5497     int[][]     r2x =   [[]];   assert(r2x.length == 1 && r2x[0].length == 0);
5498     int[][][]   r3x =   [[]];   assert(r3x.length == 1 && r3x[0].length == 0);
5499     int[][][][] r4x =   [[]];   assert(r4x.length == 1 && r4x[0].length == 0);
5500     // ----
5501     int[][][]   r3y =  [[[]]];  assert(r3y.length == 1 && r3y[0].length == 1 && r3y[0][0].length == 0);
5502     int[][][][] r4y =  [[[]]];  assert(r4y.length == 1 && r4y[0].length == 1 && r4y[0][0].length == 0);
5503     // ----
5504     int[][][][] r4z = [[[[]]]]; assert(r4z.length == 1 && r4z[0].length == 1 && r4z[0][0].length == 1 && r4z[0][0][0].length == 0);
5505 
5506     // ArrayLiteralExp conforms to the type of LHS.
5507     { auto x = a1 ~    []   ;   static assert(is(typeof(x) == typeof(a1))); assert(x == r1w); } // no ambiguity
5508     { auto x = a2 ~    []   ;   static assert(is(typeof(x) == typeof(a2))); assert(x == r2w); } // fix <- ambiguity
5509     { auto x = a3 ~    []   ;   static assert(is(typeof(x) == typeof(a3))); assert(x == r3w); } // fix <- ambiguity
5510     { auto x = a4 ~    []   ;   static assert(is(typeof(x) == typeof(a4))); assert(x == r4w); } // fix <- ambiguity
5511     // ----
5512   //{ auto x = a1 ~   [[]]  ; } // (see test14682b)
5513     { auto x = a2 ~   [[]]  ;   static assert(is(typeof(x) == typeof(a2))); assert(x == r2x); } // no ambiguity
5514     { auto x = a3 ~   [[]]  ;   static assert(is(typeof(x) == typeof(a3))); assert(x == r3x); } // fix <- ambiguity
5515     { auto x = a4 ~   [[]]  ;   static assert(is(typeof(x) == typeof(a4))); assert(x == r4x); } // fix <- ambiguity
5516     // ----
5517     static assert(!__traits(compiles, { auto x = a1 ~   [[[]]] ; }));
5518   //{ auto x = a2 ~  [[[]]] ; } // (see test14682b)
5519     { auto x = a3 ~  [[[]]] ;   static assert(is(typeof(x) == typeof(a3))); assert(x == r3y); } // no ambiguity
5520     { auto x = a4 ~  [[[]]] ;   static assert(is(typeof(x) == typeof(a4))); assert(x == r4y); } // fix <- ambiguity
5521     // ----
5522     static assert(!__traits(compiles, { auto x = a1 ~  [[[[]]]]; }));
5523     static assert(!__traits(compiles, { auto x = a2 ~  [[[[]]]]; }));
5524   //{ auto x = a3 ~ [[[[]]]]; } // (see test14682b)
5525     { auto x = a4 ~ [[[[]]]];   static assert(is(typeof(x) == typeof(a4))); assert(x == r4z); } // no ambiguity
5526 
5527     // ArrayLiteralExp conforms to the type of RHS.
5528     { auto x =    []    ~ a1;   static assert(is(typeof(x) == typeof(a1))); assert(x == r1w); } // no ambiguity
5529     { auto x =    []    ~ a2;   static assert(is(typeof(x) == typeof(a2))); assert(x == r2w); } // fix <- ambiguity
5530     { auto x =    []    ~ a3;   static assert(is(typeof(x) == typeof(a3))); assert(x == r3w); } // fix <- ambiguity
5531     { auto x =    []    ~ a4;   static assert(is(typeof(x) == typeof(a4))); assert(x == r4w); } // fix <- ambiguity
5532     // ----
5533   //{ auto x =   [[]]   ~ a1; } // (see test14682b)
5534     { auto x =   [[]]   ~ a2;   static assert(is(typeof(x) == typeof(a2))); assert(x == r2x); } // no ambiguity
5535     { auto x =   [[]]   ~ a3;   static assert(is(typeof(x) == typeof(a3))); assert(x == r3x); } // fix <- ambiguity
5536     { auto x =   [[]]   ~ a4;   static assert(is(typeof(x) == typeof(a4))); assert(x == r4x); } // fix <- ambiguity
5537     // ----
5538     static assert(!__traits(compiles, { auto x =  [[[]]]  ~ a1; }));
5539   //{ auto x =  [[[]]]  ~ a2; } // (see test14682b)
5540     { auto x =  [[[]]]  ~ a3;   static assert(is(typeof(x) == typeof(a3))); assert(x == r3y); } // no ambiguity
5541     { auto x =  [[[]]]  ~ a4;   static assert(is(typeof(x) == typeof(a4))); assert(x == r4y); } // fix <- ambiguity
5542     // ----
5543     static assert(!__traits(compiles, { auto x = [[[[]]]] ~ a1; }));
5544     static assert(!__traits(compiles, { auto x = [[[[]]]] ~ a2; }));
5545   //{ auto x = [[[[]]]] ~ a3; } // (see test14682b)
5546     { auto x = [[[[]]]] ~ a4;   static assert(is(typeof(x) == typeof(a4))); assert(x == r4z); } // no ambiguity
5547 }
5548 
5549 void test14682b()
5550 {
5551     // operands
5552     int[]       a1;
5553     int[][]     a2;
5554     int[][][]   a3;
5555     int[][][][] a4;
5556 
5557     // results
5558     int[][]     r2a = [[],   []  ]; assert(r2a.length == 2 && r2a[0].length == 0 && r2a[1].length == 0);
5559   //int[][][]   r3a = [[],  [[]] ]; // should work, but doesn't
5560   //int[][][][] r4a = [[], [[[]]]]; // should work, but doesn't
5561     int[][][]   r3a;  { r3a.length = 2; r3a[0] = []; r3a[1] =  [[]] ; }
5562                                     assert(r3a.length == 2 && r3a[0].length == 0 && r3a[1].length == 1 && r3a[1][0].length == 0);
5563     int[][][][] r4a;  { r4a.length = 2; r4a[0] = []; r4a[1] = [[[]]]; }
5564                                     assert(r4a.length == 2 && r4a[0].length == 0 && r4a[1].length == 1 && r4a[1][0].length == 1 && r4a[1][0][0].length == 0);
5565     // ----
5566     int[][]     r2b = [  []  , []]; assert(r2b.length == 2 && r2b[1].length == 0 && r2b[0].length == 0);
5567   //int[][][]   r3b = [ [[]] , []]; // should work, but doesn't
5568   //int[][][][] r4b = [[[[]]], []]; // should work, but doesn't
5569     int[][][]   r3b;  { r3b.length = 2; r3b[0] =  [[]] ; r3b[1] = []; }
5570                                     assert(r3b.length == 2 && r3b[1].length == 0 && r3b[0].length == 1 && r3b[0][0].length == 0);
5571     int[][][][] r4b;  { r4b.length = 2; r4b[0] = [[[]]]; r4b[1] = []; }
5572                                     assert(r4b.length == 2 && r4b[1].length == 0 && r4b[0].length == 1 && r4b[0][0].length == 1 && r4b[0][0][0].length == 0);
5573 
5574     // ArrayLiteralExp conforms to the typeof(LHS)->arrayOf().
5575     { auto x = a1 ~   [[]]  ;   static assert(is(typeof(x) == typeof(a1)[])); assert(x == r2a); } // fix
5576     { auto x = a2 ~  [[[]]] ;   static assert(is(typeof(x) == typeof(a2)[])); assert(x == r3a); } // fix
5577     { auto x = a3 ~ [[[[]]]];   static assert(is(typeof(x) == typeof(a3)[])); assert(x == r4a); } // fix
5578 
5579     // ArrayLiteralExp conforms to the typeof(RHS)->arrayOf().
5580     { auto x =   [[]]   ~ a1;   static assert(is(typeof(x) == typeof(a1)[])); assert(x == r2b); } // fix
5581     { auto x =  [[[]]]  ~ a2;   static assert(is(typeof(x) == typeof(a2)[])); assert(x == r3b); } // fix
5582     { auto x = [[[[]]]] ~ a3;   static assert(is(typeof(x) == typeof(a3)[])); assert(x == r4b); } // fix
5583 }
5584 
5585 
5586 /***************************************************/
5587 // https://issues.dlang.org/show_bug.cgi?id=9739
5588 
5589 class Foo9739
5590 {
5591     int val = 1;
5592     this(int arg = 2) { val = arg; }
5593 }
5594 
5595 class Bar9739 : Foo9739 { }
5596 
5597 void test9739()
5598 {
5599     Bar9739 bar = new Bar9739;
5600     assert(bar.val == 2);
5601 }
5602 
5603 /***************************************************/
5604 // https://issues.dlang.org/show_bug.cgi?id=6057
5605 void test6057()
5606 {
5607     enum Foo { A=1, B=2 }
5608     Foo[] bar = [cast(Foo)1];
5609 }
5610 
5611 /***************************************************/
5612 
5613 ulong d2ulong(double u)
5614 {
5615     return cast(ulong)u;
5616 }
5617 
5618 void testdbl_to_ulong()
5619 {
5620     auto u = d2ulong(12345.6);
5621     //writeln(u);
5622     assert(u == 12345);
5623 
5624     static if (real.mant_dig <= 64)
5625     {
5626         real adjust = 1.0L/real.epsilon;
5627         u = d2ulong(adjust);
5628         //writefln("%s %s", adjust, u);
5629         static if(real.mant_dig == 64)
5630             assert(u == 9223372036854775808UL);
5631         else static if(real.mant_dig == 53)
5632             assert(u == 4503599627370496UL);
5633         else
5634             static assert(false, "Test not implemented for this architecture");
5635 
5636         auto v = d2ulong(adjust * 1.1);
5637         //writefln("%s %s %s", adjust, v, u + u/10);
5638 
5639         // The following can vary in the last bits with different optimization settings,
5640         // i.e. the conversion from real to double may not happen.
5641         //assert(v == 10145709240540254208UL);
5642     }
5643 }
5644 
5645 /***************************************************/
5646 
5647 
5648 
5649 uint d2uint(double u)
5650 {
5651     return cast(uint)u;
5652 }
5653 
5654 void testdbl_to_uint()
5655 {
5656     auto u = d2uint(12345.6);
5657     //writeln(u);
5658     assert(u == 12345);
5659 }
5660 
5661 /***************************************************/
5662 
5663 ulong r2ulong(real u)
5664 {
5665     return cast(ulong)u;
5666 }
5667 
5668 void testreal_to_ulong()
5669 {
5670     auto u = r2ulong(12345.6L);
5671     //writeln(u);
5672     assert(u == 12345);
5673 
5674     real adjust = 1.0L/real.epsilon;
5675     u = r2ulong(adjust);
5676     //writefln("%s %s", adjust, u);
5677     static if(real.mant_dig == 113)
5678         assert(u == 18446744073709551615UL);
5679     else static if(real.mant_dig == 106)
5680         assert(u == 18446744073709551615UL);
5681     else static if(real.mant_dig == 64)
5682         assert(u == 9223372036854775808UL);
5683     else static if(real.mant_dig == 53)
5684         assert(u == 4503599627370496UL);
5685     else
5686         static assert(false, "Test not implemented for this architecture");
5687 
5688     auto v = r2ulong(adjust * 1.1);
5689     //writefln("%s %s %s", adjust, v, u + u/10);
5690 
5691     //assert(v == 10145709240540253389UL);
5692 }
5693 
5694 /***************************************************/
5695 
5696 long testbt1(long a, long b, int c)
5697 {
5698     return a + ((b >> c) & 1);
5699 //    return a + ((b & (1L << c)) != 0);
5700 }
5701 
5702 
5703 long testbt2(long a, long b, int c)
5704 {
5705 //    return a + ((b >> c) & 1);
5706     return a + ((b & (1L << c)) != 0);
5707 }
5708 
5709 int testbt3(int a, int b, int c)
5710 {
5711     return a + ((b >> c) & 1);
5712 //    return a + ((b & (1 << c)) != 0);
5713 }
5714 
5715 int testbt4(int a, int b, int c)
5716 {
5717 //    return a + ((b >> c) & 1);
5718     return a + ((b & (1 << c)) != 0);
5719 }
5720 
5721 
5722 void test248()
5723 {
5724     auto a1 = testbt1(3, 4, 2);
5725     assert(a1 == 4);
5726     a1 = testbt2(3, 4, 2);
5727     assert(a1 == 4);
5728     a1 = testbt3(3, 4, 2);
5729     assert(a1 == 4);
5730     a1 = testbt4(3, 4, 2);
5731     assert(a1 == 4);
5732 
5733     a1 = testbt1(3, 8, 2);
5734     assert(a1 == 3);
5735     a1 = testbt2(3, 8, 2);
5736     assert(a1 == 3);
5737     a1 = testbt3(3, 8, 2);
5738     assert(a1 == 3);
5739     a1 = testbt4(3, 8, 2);
5740     assert(a1 == 3);
5741 }
5742 
5743 /***************************************************/
5744 
5745 int foo249(int a, int b)
5746 {
5747     return a + ((b & 0x80) != 0);
5748 }
5749 
5750 long bar249(long a, int b)
5751 {
5752     return a + ((b & 0x80) != 0);
5753 }
5754 
5755 void test249()
5756 {
5757   {
5758     auto i = foo249(3, 6);
5759     assert(i == 3);
5760     i = foo249(3, 0x88);
5761     assert(i == 4);
5762   }
5763   {
5764     auto i = bar249(3, 6);
5765     assert(i == 3);
5766     i = bar249(3, 0x88);
5767     assert(i == 4);
5768   }
5769 }
5770 
5771 /***************************************************/
5772 
5773 // These should all compile to a BT instruction when -O, for -m32 and -m64
5774 
5775 int bt32(uint *p, uint b) { return ((p[b >> 5] & (1 << (b & 0x1F)))) != 0; }
5776 
5777 int bt64a(ulong *p, uint b) { return ((p[b >> 6] & (1L << (b & 63)))) != 0; }
5778 
5779 int bt64b(ulong *p, size_t b) { return ((p[b >> 6] & (1L << (b & 63)))) != 0; }
5780 
5781 void test250()
5782 {
5783     static uint[2]  a1 = [0x1001_1100, 0x0220_0012];
5784 
5785     if ( bt32(a1.ptr,30)) assert(0);
5786     if (!bt32(a1.ptr,8))  assert(0);
5787     if ( bt32(a1.ptr,30+32)) assert(0);
5788     if (!bt32(a1.ptr,1+32))  assert(0);
5789 
5790     static ulong[2] a2 = [0x1001_1100_12345678, 0x0220_0012_12345678];
5791 
5792     if ( bt64a(a2.ptr,30+32)) assert(0);
5793     if (!bt64a(a2.ptr,8+32))  assert(0);
5794     if ( bt64a(a2.ptr,30+32+64)) assert(0);
5795     if (!bt64a(a2.ptr,1+32+64))  assert(0);
5796 
5797     if ( bt64b(a2.ptr,30+32)) assert(0);
5798     if (!bt64b(a2.ptr,8+32))  assert(0);
5799     if ( bt64b(a2.ptr,30+32+64)) assert(0);
5800     if (!bt64b(a2.ptr,1+32+64))  assert(0);
5801 }
5802 
5803 /***************************************************/
5804 
5805 struct S251 { int a,b,c,d; }
5806 
5807 S251 foo251(S251 s)
5808 {
5809     S251 a = s;
5810     S251 b = a; // copy propagation
5811     S251 c = b;
5812     S251 d = c;
5813     S251 e = d; // dead assignment
5814     return d;
5815 }
5816 
5817 void test251()
5818 {
5819     S251 a;
5820     a.a = 1;
5821     a.b = 2;
5822     a.c = 3;
5823     a.d = 4;
5824     a = foo251(a);
5825     assert(a.a == 1);
5826     assert(a.b == 2);
5827     assert(a.c == 3);
5828     assert(a.d == 4);
5829 }
5830 
5831 /***************************************************/
5832 // https://issues.dlang.org/show_bug.cgi?id=9387
5833 
5834 void bug9387a(double x) { }
5835 
5836 void ice9387()
5837 {
5838     double x = 0.3;
5839     double r = x*0.1;
5840     double q = x*0.1 + r;
5841     double p = x*0.1 + r*0.2;
5842     if ( q )
5843         p = -p;
5844     bug9387a(p);
5845 }
5846 
5847 /***************************************************/
5848 
5849 void bug6962(string value)
5850 {
5851     string v = value;
5852     try
5853     {
5854         v = v[0LU..0LU];
5855         return;
5856     }
5857     finally
5858     {
5859         assert(!v.length);
5860     }
5861 }
5862 
5863 void test6962()
5864 {
5865     bug6962("42");
5866 }
5867 
5868 /***************************************************/
5869 
5870 int[1] foo4414() {
5871     return [7];
5872 }
5873 
5874 ubyte[4] bytes4414()
5875 {
5876     ubyte[4] x;
5877     x[0] = 7;
5878     x[1] = 8;
5879     x[2] = 9;
5880     x[3] = 10;
5881     return x;
5882 }
5883 
5884 void test4414() {
5885   {
5886     int x = foo4414()[0];
5887     assert(x == 7);
5888   }
5889   {
5890     auto u = bytes4414();
5891     auto x = u[0..4];
5892     if (x[0] != 7 || x[1] != 8 || x[2] != 9 || x[3] != 10)
5893         assert(0);
5894   }
5895   assert(bytes4414()[0] == 7);
5896   assert(bytes4414()[1] == 8);
5897   assert(bytes4414()[2] == 9);
5898   assert(bytes4414()[3] == 10);
5899 }
5900 
5901 /***************************************************/
5902 
5903 void test9844() {
5904     int a = -1;
5905     long b = -1;
5906     assert(a == -1);
5907     assert(b == -1L);
5908 }
5909 
5910 /***************************************************/
5911 // https://issues.dlang.org/show_bug.cgi?id=10628
5912 
5913 abstract class B10628
5914 {
5915     static if (! __traits(isVirtualMethod, foo))
5916     {
5917     }
5918 
5919     private bool _bar;
5920     public void foo();
5921 }
5922 
5923 class D10628 : B10628
5924 {
5925     public override void foo() {}
5926 }
5927 
5928 void test10628()
5929 {
5930     assert(typeid(D10628).vtbl.length - typeid(Object).vtbl.length == 1);
5931 }
5932 
5933 /***************************************************/
5934 // https://issues.dlang.org/show_bug.cgi?id=11265
5935 
5936 struct S11265
5937 {
5938     class InnerClass
5939     {
5940         S11265 s;
5941 
5942         bool empty()
5943         {
5944             return true;
5945         }
5946     }
5947 }
5948 
5949 void test11265()
5950 {
5951     S11265.InnerClass trav = new S11265.InnerClass();
5952     trav.empty();
5953 }
5954 
5955 /***************************************************/
5956 
5957 struct TimeOfDay
5958 {
5959     void roll(int value)
5960     {
5961         value %= 60;
5962         auto newVal = _seconds + value;
5963 
5964         if(newVal < 0)
5965             newVal += 60;
5966         else if(newVal >= 60)
5967             newVal -= 60;
5968 
5969         _seconds = cast(ubyte)newVal;
5970     }
5971 
5972     ubyte _seconds;
5973 }
5974 
5975 
5976 void test10633()
5977 {
5978     TimeOfDay tod = TimeOfDay(0);
5979     tod.roll(-1);
5980     assert(tod._seconds == 59);
5981 }
5982 
5983 /***************************************************/
5984 
5985 void _assertEq (ubyte lhs, short rhs, string msg, string file, size_t line)
5986 {
5987     immutable result = lhs == rhs;
5988 
5989     if(!result)
5990     {
5991         string op = "==";
5992         if(msg.length > 0)
5993             printf("_assertEq failed: [%u] is not [%d].\n", lhs, rhs);
5994         else
5995             printf("_assertEq failed: [%u] is not [%d]: %.*s\n", lhs, rhs, cast(int)msg.length, msg.ptr);
5996     }
5997 
5998     assert(result);
5999 }
6000 
6001 struct Date
6002 {
6003     short year;
6004     ubyte month;
6005     ubyte day;
6006 }
6007 
6008 struct MonthDay
6009 {
6010     ubyte month;
6011     short day;
6012 }
6013 
6014 void test10642()
6015 {
6016     static void test(Date date, int day, MonthDay expected, size_t line = __LINE__)
6017     {
6018         _assertEq(date.day, expected.day, "", __FILE__, line);
6019     }
6020 
6021     test(Date(1999, 1, 1), 1, MonthDay(1,1));
6022 }
6023 
6024 /***************************************************/
6025 // https://issues.dlang.org/show_bug.cgi?id=11581
6026 
6027 alias TT11581(T...) = T;
6028 
6029 void test11581()
6030 {
6031     static class A {}
6032 
6033     static class C { alias Types = TT11581!(4, int); }
6034     static C makeC() { return null; }
6035 
6036     alias T = TT11581!(A);
6037 
6038     // edim == IntergerExp(0)
6039     auto a1 = new T[0];
6040     static assert(is(typeof(a1) == A));
6041 
6042     enum d2 = 0;
6043 
6044     // edim == TypeIdentifier('d2') --> IdentifierExp
6045     auto a2 = new T[d2];
6046     static assert(is(typeof(a2) == A));
6047 
6048     alias U = int;
6049     int d3 = 3;
6050 
6051     // edim == TypeIdentifier('d3') --> IdentifierExp
6052     auto a3 = new U[d3];
6053     static assert(is(typeof(a3) == U[]));
6054     assert(a3.length == d3);
6055 
6056     // edim == IndexExp(DotIdExp(CallExp(makeC, []), 'Types'), 0)
6057     auto a4 = new U[makeC().Types[0]];
6058     static assert(is(typeof(a4) == U[]));
6059     assert(a4.length == C.Types[0]);
6060 }
6061 
6062 /***************************************************/
6063 // https://issues.dlang.org/show_bug.cgi?id=7436
6064 
6065 void test7436()
6066 {
6067     ubyte a = 10;
6068     float f = 6;
6069     ubyte b = a += f;
6070     assert(b == 16);
6071 }
6072 
6073 /***************************************************/
6074 // https://issues.dlang.org/show_bug.cgi?id=12138
6075 
6076 struct S12138
6077 {
6078     int num;
6079     this(int n) { num = n; }
6080     ~this() { num = 0; }
6081 }
6082 
6083 void test12138()
6084 {
6085 label:
6086     auto s = S12138(10);
6087     assert(s.num == 10);
6088 }
6089 
6090 /***************************************************/
6091 // https://issues.dlang.org/show_bug.cgi?id=14430
6092 
6093 void setCookie(long x = 1L << 32L, string y = null){
6094     assert(y.ptr is null);
6095 }
6096 
6097 void test14430(){
6098     setCookie();
6099 }
6100 
6101 /***************************************************/
6102 // https://issues.dlang.org/show_bug.cgi?id=14510
6103 
6104 alias Vector14510 = ulong[3];
6105 
6106 void fun14510(Vector14510 vec, bool recursive = false)
6107 {
6108     assert(vec[2] == 0);
6109     if (recursive)
6110         return;
6111     fun14510(vec, true);
6112 }
6113 
6114 void test14510()
6115 {
6116     Vector14510 vec;
6117     fun14510(vec);
6118 }
6119 
6120 /***************************************************/
6121 // https://issues.dlang.org/show_bug.cgi?id=16027
6122 
6123 void test16027()
6124 {
6125     double value = 1.0;
6126     value *= -1.0;
6127     assert(value == -1.0);    // fails, value is +1.0
6128 
6129     value = 1.0;
6130     value = value * -1.0;
6131     assert(value == -1.0);
6132 }
6133 
6134 /***************************************************/
6135 // https://issues.dlang.org/show_bug.cgi?id=16530
6136 
6137 double entropy2(double[] probs)
6138 {
6139     double result = 0;
6140     foreach (p; probs)
6141     {
6142         __gshared int x;
6143         ++x;
6144         if (!p) continue;
6145         import core.stdc.math : log2;
6146         result -= p * log2(p);
6147     }
6148     return result;
6149 }
6150 
6151 void test16530()
6152 {
6153     if (entropy2([1.0, 0, 0]) != 0.0)
6154        assert(0);
6155 }
6156 
6157 /***************************************************/
6158 
6159 void test252()
6160 {
6161     __gshared int x = 7;
6162     __gshared long y = 217;
6163     if ((-1 - x) != ~x)
6164         assert(0);
6165     if ((-1 - y) != ~y)
6166         assert(0);
6167 }
6168 
6169 /***************************************************/
6170 // https://issues.dlang.org/show_bug.cgi?id=7997
6171 
6172 void test7997()
6173 {
6174     __gshared int[0] foos;
6175     foreach (f; foos) {}
6176 }
6177 
6178 /***************************************************/
6179 // https://issues.dlang.org/show_bug.cgi?id=5332
6180 
6181 int[0] arr5332;
6182 
6183 void test5332()
6184 {
6185     auto a = arr5332;
6186 }
6187 
6188 /***************************************************/
6189 // https://issues.dlang.org/show_bug.cgi?id=11742
6190 
6191 const int x11472 = void;
6192 
6193 static this() { x11472 = 10; }
6194 
6195 void test11472()
6196 {
6197     assert(x11472 == 10);
6198 }
6199 
6200 
6201 /***************************************************/
6202 
6203 int main()
6204 {
6205     checkAlign();
6206     test1();
6207     test2();
6208     test3();
6209     test4();
6210     test5();
6211     test6();
6212     test7();
6213     test8();
6214     test9();
6215     test10();
6216     test11();
6217     test12();
6218     test13();
6219     test14();
6220     test15();
6221     test16();
6222     test17();
6223     test18();
6224     test19();
6225     test20();
6226     test21();
6227     test22();
6228     test23();
6229     test24();
6230     test25();
6231     test27();
6232     test28();
6233     test29();
6234     test31();
6235     test32();
6236     test33();
6237     test34();
6238     test35();
6239     test36();
6240     test37();
6241     test38();
6242     test39();
6243     test40();
6244     test41();
6245     test42();
6246     test43();
6247     test44();
6248     test45();
6249     test46();
6250     test47();
6251     test48();
6252     test49();
6253     test50();
6254     test51();
6255     test52();
6256     test53();
6257     test54();
6258     test55();
6259     test56();
6260     test57();
6261     test58();
6262     test59();
6263     test60();
6264     test61();
6265     test62();
6266     test63();
6267     test64();
6268     test65();
6269     test66();
6270     test67();
6271     test68();
6272     test69();
6273     test70();
6274     test71();
6275     test72();
6276     test73();
6277     test74();
6278     test75();
6279     test76();
6280     test77();
6281     test78();
6282     test79();
6283     test80();
6284     test81();
6285     test82();
6286     test83();
6287     test84();
6288     test85();
6289     test86();
6290     test87();
6291     test88();
6292     test89();
6293     test90();
6294     test91();
6295     test92();
6296     test93();
6297     test94();
6298     test95();
6299     test96();
6300     test97();
6301     test98();
6302     test99();
6303     test100();
6304     test101();
6305     test103();
6306     test104();
6307     test105();
6308     test107();
6309     test108();
6310     test109();
6311     test110();
6312     test111();
6313     test112();
6314     test113();
6315     test114();
6316     test115();
6317     test116();
6318     test117();
6319     test118();
6320     test119();
6321     test120();
6322     test121();
6323     //test122();
6324     test123();
6325     test124();
6326     test125();
6327     test126();
6328     test127();
6329     test128();
6330     test129();
6331     test130();
6332     test131();
6333     test132();
6334     test133();
6335 
6336 //    test135();
6337     test136();
6338     test137();
6339 
6340     test139();
6341     test140();
6342 
6343     test142();
6344     test143();
6345     test144();
6346     test145();
6347     test146();
6348     test147();
6349     test148();
6350     test149();
6351 
6352     test151();
6353     test152();
6354     test153();
6355     test154();
6356 
6357     test156();
6358     test157();
6359 
6360     test160();
6361 
6362     test163();
6363 
6364 
6365     test169();
6366 
6367     test171();
6368 
6369     test173();
6370     test174();
6371 
6372     test176();
6373     test177();
6374 
6375     test179();
6376 
6377     test181();
6378     test182();
6379 
6380     test188();
6381     test189();
6382     test190();
6383     test191();
6384 
6385     test193();
6386     test194();
6387 
6388     test198();
6389 
6390     test200();
6391     test201();
6392     test202();
6393     test203();
6394 
6395 //    test208();
6396 
6397     test210();
6398 
6399     test212();
6400     test213();
6401     test214();
6402     test215();
6403     test216();
6404     test217();
6405     test218();
6406     test219();
6407     test220();
6408 
6409     test222();
6410     test223();
6411     test224();
6412     test225();
6413     test226();
6414     test227();
6415     test228();
6416     test229();
6417     test230();
6418     test230();
6419     bug5717();
6420     test231();
6421     test232();
6422     test233();
6423     bug6184();
6424     test236();
6425     test237();
6426     test238();
6427     test239();
6428     test6229();
6429     test6270();
6430     test6506();
6431     test240();
6432     test6563();
6433     test241();
6434     test6665();
6435     test5364();
6436     test6189();
6437     test6997();
6438     test7026();
6439     test6354();
6440     test7072();
6441     test7212();
6442     test242();
6443     test7290();
6444     test7367();
6445     test7375();
6446     test6504();
6447     test7422();
6448     test7424();
6449     test7502();
6450     test4820();
6451     test4820_2();
6452     test243();
6453     test7742();
6454     test245();
6455     test7807();
6456     test4155();
6457     test7911();
6458     test8095();
6459     test8091();
6460     test6189_2();
6461     test8199();
6462     test246();
6463     test8454();
6464     test8423();
6465     test8496();
6466     test8840();
6467     test8889();
6468     test8870();
6469     test9781();
6470     test247();
6471     test8340();
6472     test8376();
6473     test8796();
6474     test9171();
6475     test9248();
6476     test14682a();
6477     test14682b();
6478     test9739();
6479     testdbl_to_ulong();
6480     testdbl_to_uint();
6481     testreal_to_ulong();
6482     test248();
6483     test249();
6484     test250();
6485     test6057();
6486     test251();
6487     test6962();
6488     test4414();
6489     test9844();
6490     test10628();
6491     test11265();
6492     test10633();
6493     test10642();
6494     test11581();
6495     test7436();
6496     test12138();
6497     test14430();
6498     test14510();
6499     test16027();
6500     test16530();
6501     test252();
6502     test7997();
6503     test5332();
6504     test11472();
6505     test13285();
6506 
6507     printf("Success\n");
6508     return 0;
6509 }