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




------- Comment #1 from gide nwawudu.com  2008-04-28 10:02 -------
*** 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




------- Comment #2 from bugzilla digitalmars.com  2008-06-15 19:22 -------
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                  |




------- Comment #3 from samukha voliacable.com  2008-06-16 02:13 -------
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





------- Comment #4 from samukha voliacable.com  2008-06-17 10:09 -------
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




------- Comment #5 from smjg iname.com  2008-11-21 15:20 -------
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





------- Comment #6 from smjg iname.com  2008-11-21 15:24 -------
*** 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




------- Comment #7 from samukha voliacable.com  2008-11-24 07:25 -------
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





------- Comment #8 from clugdbug yahoo.com.au  2008-11-25 06:48 -------
For what it's worth, I can also confirm that this is fixed.


-- 
Nov 25 2008