[Issue 3198] New: wrong initializer for structs arrays
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Jul 21 10:20:15 PDT 2009
http://d.puremagic.com/issues/show_bug.cgi?id=3198
Summary: wrong initializer for structs arrays
Product: D
Version: 1.046
Platform: x86
OS/Version: All
Status: NEW
Keywords: wrong-code
Severity: major
Priority: P2
Component: DMD
AssignedTo: nobody at puremagic.com
ReportedBy: nfxjfg at gmail.com
The following example compiles, but the output is wrong. It seems the
initializer for a struct array is ignored; instead, the default initializer of
the struct is used for the array.
import std.stdio;
import std.string;
struct T {
int g = 1;
string toString() {
return format("%s", g);
}
}
class Foo {
int[5] x = 4;
//this doesn't work
//basically, the "=T(4)" part is ignored
T[5] y = T(4);
}
void main() {
auto f = new Foo();
//both lines should output the same
//but it shows f.y is [1,1,1,1,1]
writefln("f.x = %s", f.x);
writefln("f.y = %s", f.y);
}
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list