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

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:
------- You are receiving this mail because: -------

Reply via email to