Thread overview
array initialization in template
Oct 29, 2004
tetsuya
Oct 31, 2004
Thomas Kuehne
Nov 01, 2004
tetsuya
October 29, 2004
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


October 31, 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



November 01, 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
>
>
>