Thread overview | |||||
---|---|---|---|---|---|
|
March 12, 2008 Array initialisation from const array; | ||||
---|---|---|---|---|
| ||||
The following code prints 0. Why is this? import std.stdio; struct S1 { const float[10] i = [0,0,0,0,0,0,0,0,0,0]; float a[10] = i; int y=5; } void main() { S1 s; writefln(s.y); } DMD linux: Digital Mars D Compiler v1.028 Copyright (c) 1999-2008 by Digital Mars written by Walter Bright Documentation: http://www.digitalmars.com/d/1.0/index.html And the same for 1.026 on Windows. |
March 12, 2008 Re: Array initialisation from const array; | ||||
---|---|---|---|---|
| ||||
Posted in reply to Spacen Jasset | Spacen Jasset wrote:
> The following code prints 0. Why is this?
>
> import std.stdio;
>
> struct S1
> {
> const float[10] i = [0,0,0,0,0,0,0,0,0,0];
> float a[10] = i;
> int y=5;
> }
>
>
> void main()
> {
> S1 s;
> writefln(s.y);
> }
>
> DMD linux:
>
> Digital Mars D Compiler v1.028
> Copyright (c) 1999-2008 by Digital Mars written by Walter Bright
> Documentation: http://www.digitalmars.com/d/1.0/index.html
>
> And the same for 1.026 on Windows.
I have filed bug #1914 on this. This cannot be right.
|
April 01, 2008 Re: Array initialisation from const array; | ||||
---|---|---|---|---|
| ||||
Posted in reply to Spacen Jasset | Spacen Jasset Wrote:
> Spacen Jasset wrote:
> > The following code prints 0. Why is this?
> >
> > import std.stdio;
> >
> > struct S1
> > {
> > const float[10] i = [0,0,0,0,0,0,0,0,0,0];
> > float a[10] = i;
> > int y=5;
> > }
> >
> >
> > void main()
> > {
> > S1 s;
> > writefln(s.y);
> > }
> >
> > DMD linux:
> >
> > Digital Mars D Compiler v1.028
> > Copyright (c) 1999-2008 by Digital Mars written by Walter Bright
> > Documentation: http://www.digitalmars.com/d/1.0/index.html
> >
> > And the same for 1.026 on Windows.
>
> I have filed bug #1914 on this. This cannot be right.
Did you get an answeron ths ? Same result in Tango /dmd1.028/linux
|
Copyright © 1999-2021 by the D Language Foundation