# HG changeset patch # User thomask # Date 1175718844 0 # Node ID 623963e374c5fe750e2c0e5ac3059d553caa1296 # Parent 2322c29c00beb3a6da4063061b7e8b0b104ec2d7 [Issue 1088] structs allocated with a struct allocator will not have default initializer values assigned Mark Guidarelli 2007-03-31 http://d.puremagic.com/issues/show_bug.cgi?id=1088 diff -r 2322c29c00be -r 623963e374c5 run/l/lazy_03_A.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/run/l/lazy_03_A.d Wed Apr 04 20:34:04 2007 +0000 @@ -0,0 +1,46 @@ +// $HeadURL$ +// $Date$ +// $Author$ + +// @author@ Mark Guidarelli +// @date@ 2007-03-31 +// @uri@ http://d.puremagic.com/issues/show_bug.cgi?id=1088 +// @desc@ [Issue 1088] structs allocated with a struct allocator will not have default initializer values assigned + +module dstress.run.l.lazy_03_A; + +int step; +int[] master = [0x12_34_56_78, 0x12_34_56_78, 0xAB_CD_EF_00, 0xAB_CD_EF_00]; + +void test(...){ + if(1 != _arguments.length){ + assert(0); + } + if(typeid(int) != _arguments[0]){ + assert(0); + } + int i = va_arg!(int)(_argptr); + if(master[step] != i){ + assert(0); + } + step++; +} + +int foo() { + test(0x12_34_56_78); + return 0xAB_CD_EF_00; +} + +void bar(lazy int[] bla ...) { + foreach (elem; bla){ + test(elem); + } +} + +int main() { + bar(foo(), foo()); + if(step != master.length){ + assert(0); + } + return 0; +} diff -r 2322c29c00be -r 623963e374c5 run/l/lazy_03_B.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/run/l/lazy_03_B.d Wed Apr 04 20:34:04 2007 +0000 @@ -0,0 +1,39 @@ +// $HeadURL$ +// $Date$ +// $Author$ + +// @author@ Mark Guidarelli +// @date@ 2007-03-31 +// @uri@ http://d.puremagic.com/issues/show_bug.cgi?id=1088 +// @desc@ [Issue 1088] structs allocated with a struct allocator will not have default initializer values assigned + +module dstress.run.l.lazy_03_B; + +int step; +int[] master = [0x12_34_56_78, 0x12_34_56_78, 0xAB_CD_EF_00, 0xAB_CD_EF_00]; + +void test(int i){ + if(master[step] != i){ + assert(0); + } + step++; +} + +int foo() { + test(0x12_34_56_78); + return 0xAB_CD_EF_00; +} + +void bar(lazy int[] bla ...) { + foreach (elem; bla){ + test(elem); + } +} + +int main() { + bar(foo(), foo()); + if(step != master.length){ + assert(0); + } + return 0; +} diff -r 2322c29c00be -r 623963e374c5 run/l/lazy_03_C.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/run/l/lazy_03_C.d Wed Apr 04 20:34:04 2007 +0000 @@ -0,0 +1,48 @@ +// $HeadURL$ +// $Date$ +// $Author$ + +// @author@ Mark Guidarelli +// @date@ 2007-03-31 +// @uri@ http://d.puremagic.com/issues/show_bug.cgi?id=1088 +// @desc@ [Issue 1088] structs allocated with a struct allocator will not have default initializer values assigned + +module dstress.run.l.lazy_03_C; + +import std.stdarg; + +int step; +int[] master = [0x12_34_56_78, 0x12_34_56_78, 0xAB_CD_EF_00, 0xAB_CD_EF_00]; + +void test(...){ + if(1 != _arguments.length){ + assert(0); + } + if(typeid(int) != _arguments[0]){ + assert(0); + } + int i = va_arg!(int)(_argptr); + if(master[step] != i){ + assert(0); + } + step++; +} + +int foo() { + test(0x12_34_56_78); + return 0xAB_CD_EF_00; +} + +void bar(lazy int[] bla ...) { + foreach (elem; bla){ + test(elem); + } +} + +int main() { + bar([foo(), foo()]); + if(step != master.length){ + assert(0); + } + return 0; +} diff -r 2322c29c00be -r 623963e374c5 run/l/lazy_03_D.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/run/l/lazy_03_D.d Wed Apr 04 20:34:04 2007 +0000 @@ -0,0 +1,48 @@ +// $HeadURL$ +// $Date$ +// $Author$ + +// @author@ Mark Guidarelli +// @date@ 2007-03-31 +// @uri@ http://d.puremagic.com/issues/show_bug.cgi?id=1088 +// @desc@ [Issue 1088] structs allocated with a struct allocator will not have default initializer values assigned + +module dstress.run.l.lazy_03_D; + +import std.stdarg; + +int step; +int[] master = [0x12_34_56_78, 0x12_34_56_78, 0xAB_CD_EF_00, 0xAB_CD_EF_00]; + +void test(...){ + if(1 != _arguments.length){ + assert(0); + } + if(typeid(int) != _arguments[0]){ + assert(0); + } + int i = va_arg!(int)(_argptr); + if(master[step] != i){ + assert(0); + } + step++; +} + +int foo() { + test(0x12_34_56_78); + return 0xAB_CD_EF_00; +} + +void bar(lazy int[] bla) { + foreach (elem; bla){ + test(elem); + } +} + +int main() { + bar([foo(), foo()]); + if(step != master.length){ + assert(0); + } + return 0; +}