digitalmars.D.bugs - array initialization in template
- tetsuya (21/21) Oct 29 2004 dmd 1.04, winXP
- Thomas Kuehne (6/27) Oct 31 2004 added to dstress as
- tetsuya (3/38) Nov 01 2004 then it must be a windows specific problem, anyway..
dmd 1.04, winXP
looks like the initialization of an array in a class
in a template is missing...
try this code.
<code>
template Foo(T, int L)
{
T[L] arr;
class Bar { T[L] arr; }
}
unittest
{
alias Foo!(int, 100) foo;
foreach (int x; foo.arr)
assert(x == int.init); // initialized, no problem
foo.Bar bar = new foo.Bar();
foreach (int x; bar.arr)
assert(x == int.init); // not initialized, fails
}
</code>
tetsuya
Oct 29 2004
added to dstress as
svn://svn.kuehne.cn/dstress/run/array_initialization_03.d .
It should work, and in fact does so on Linux.
Either this is a Windows spezific problem or you code snipplet is incomplete.
Thomas
tetsuya schrieb:
dmd 1.04, winXP
looks like the initialization of an array in a class
in a template is missing...
try this code.
<code>
template Foo(T, int L)
{
T[L] arr;
class Bar { T[L] arr; }
}
unittest
{
alias Foo!(int, 100) foo;
foreach (int x; foo.arr)
assert(x == int.init); // initialized, no problem
foo.Bar bar = new foo.Bar();
foreach (int x; bar.arr)
assert(x == int.init); // not initialized, fails
}
</code>
tetsuya
Oct 31 2004
then it must be a windows specific problem, anyway.. thanks for the report In article <cm3l21$1peu$4 digitaldaemon.com>, Thomas Kuehne says...added to dstress as svn://svn.kuehne.cn/dstress/run/array_initialization_03.d . It should work, and in fact does so on Linux. Either this is a Windows spezific problem or you code snipplet is incomplete. Thomas tetsuya schrieb:dmd 1.04, winXP looks like the initialization of an array in a class in a template is missing... try this code. <code> template Foo(T, int L) { T[L] arr; class Bar { T[L] arr; } } unittest { alias Foo!(int, 100) foo; foreach (int x; foo.arr) assert(x == int.init); // initialized, no problem foo.Bar bar = new foo.Bar(); foreach (int x; bar.arr) assert(x == int.init); // not initialized, fails } </code> tetsuya
Nov 01 2004








tetsuya <tetsuya_member pathlink.com>