www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 1768] New: CTFE: cant ~= an array literal to an unitinitialized array

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1768

           Summary: CTFE: cant ~= an array literal to an unitinitialized
                    array
           Product: D
           Version: 1.025
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: clugdbug yahoo.com.au


The bug is illustrated in case (c). Case (d) shows a workaround: explicitly
initialize the array with [].
---------
char [] foo()
{
   char [] a;
   a ~="abc"; // ok
   char [][] b;
   b ~= "abc"; // ok
   char [][][] c;
   c ~= ["abc", "def"]; // Error: cannot eval at compile time
   char [][][] d = [];
   d ~= ["abc", "def"]; // ok
   return "abc";   
}

const xx = foo();


-- 
Jan 03 2008
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1768


gide nwawudu.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bartosz relisoft.com





*** Bug 2009 has been marked as a duplicate of this bug. ***


-- 
Apr 28 2008
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1768


bugzilla digitalmars.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |WORKSFORME





Works in dmd 1.030 and 2.014 (after replaceing all char[] with string).


-- 
Jun 15 2008
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1768


samukha voliacable.com changed:

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





Please recheck. Both compilers fail for me. Other people was having the issue
too.

dmd 1.030:

char [] foo()
{
   char [][][] c;
   c ~= ["abc", "def"]; // Error: cannot eval at compile time

    return null;
}

const xx = foo();


dmd 2.014:

char [] foo()
{
   string[][] c;
   c ~= ["abc", "def"]; // Error: cannot eval at compile time

    return null;
}

const xx = foo();


-- 
Jun 16 2008
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1768






While you are at it, please ensure that this works too:

(For dmd 1.030)

char[][] foo(char[][] a = null)
{
    a ~= ["oops"];
    return a;
}

static assert(foo()[0] == "oops");


-- 
Jun 17 2008
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1768


smjg iname.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |smjg iname.com





Cannot reproduce on 1.026 or 2.019.  Is anyone else still seeing this problem?


-- 
Nov 21 2008
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1768






*** Bug 2009 has been marked as a duplicate of this bug. ***


-- 
Nov 21 2008
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1768


samukha voliacable.com changed:

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





These seem to have been fixed except for the one with null as default argument
but it's a different bug. And there are still bugs related to uninitialized
arrays in structs.


-- 
Nov 24 2008
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1768






For what it's worth, I can also confirm that this is fixed.


-- 
Nov 25 2008