[Issue 15153] CTFE failes to access second dimension of static arrays

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Sun Oct 4 12:46:23 PDT 2015


https://issues.dlang.org/show_bug.cgi?id=15153

tobias.marstaller at gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|INVALID                     |---

--- Comment #2 from tobias.marstaller at gmail.com ---
Okey, i understand that. I changed my test snippet to this but the compiler
still gives an error for the array declaration:

----
module std.test;

static int[][] staticTable = [[1, 2], [3, 4]];
static int[][] staticallyDerivedTable = deriveTable(staticTable);

static int[][] deriveTable(int[][] table)
{
    int[table.length][table[0].length] newTable;

    // ... do something

    return newTable;
}
----


I switchted to use a dynamic array, which works:

----
module std.test;

static int[][] staticTable = [[1, 2], [3, 4]];
static int[][] staticallyDerivedTable = deriveTable(staticTable);

static int[][] deriveTable(int[][] table)
{
    int[][] newTable = new int[][](table[0].length, table.length);

    // ... do something

    return newTable;
}
----

--


More information about the Digitalmars-d-bugs mailing list