Thread overview
[Issue 3826] New: init of fixed sized arrays
Mar 10, 2010
Philippe Sigaud
Feb 01, 2012
yebblies
February 18, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3826

           Summary: init of fixed sized arrays
           Product: D
           Version: 2.040
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: druntime
        AssignedTo: sean@invisibleduck.org
        ReportedBy: bearophile_hugs@eml.cc


--- Comment #0 from bearophile_hugs@eml.cc 2010-02-18 12:36:30 PST ---
import std.stdio: writeln;
void main() {
    alias int[2] T;
    writeln(T.init);
}

I'd like this program has to print [0,0] instead of 0, otherwise generic code that uses ".init" breaks (I have had to create a function that avoids me to special-cases such arrays).

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
March 10, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3826


Philippe Sigaud <philippe.sigaud@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |philippe.sigaud@gmail.com


--- Comment #1 from Philippe Sigaud <philippe.sigaud@gmail.com> 2010-03-10 21:58:34 CET ---
It's even more general than that: (T[n]).init is T.init. It's not even the
correct type!
That seems wrong to me. It should be a T[n] filled with T.init.

int[2] i2; double[3] d2; char[1] c2; string[0] s2;
writeln(typeof(i2).stringof, " ", typeof(typeof(i2).init).stringof);// int[2]
int
writeln(typeof(d2).stringof, " ", typeof(typeof(d2).init).stringof);//
double[3] double

void f(int a) {}
void g(int[2] a) {}

auto i3 = (int[2]).init;
f(i3); // Works. i3 is of type int.
g(i3); // Does not work. i3 is of type int.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
March 28, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3826



--- Comment #2 from bearophile_hugs@eml.cc 2010-03-28 06:26:01 PDT ---
(Probably) fixed in changeset 422

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
February 01, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=3826


yebblies <yebblies@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |yebblies@gmail.com
           Platform|x86                         |All
            Version|2.040                       |D1 & D2
         Resolution|                            |FIXED
         OS/Version|Windows                     |All


--- Comment #3 from yebblies <yebblies@gmail.com> 2012-02-02 03:11:46 EST ---
This works as expected with the current compiler (2.058 & 1.072)

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------