Thread overview
[Issue 1375] New: CTFE fails for null arrays
Jul 25, 2007
d-bugmail
Jul 26, 2007
d-bugmail
Jul 26, 2007
d-bugmail
[Issue 1375] CTFE fails for null strings and arrays
Jul 02, 2008
d-bugmail
Jan 07, 2009
d-bugmail
Apr 06, 2009
d-bugmail
July 25, 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1375

           Summary: CTFE fails for null arrays
           Product: D
           Version: 1.019
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Severity: major
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla@digitalmars.com
        ReportedBy: samukha@voliacable.com


Neither of the if's compile:

int foo()
{
    char[] s;

    if (s)
    {
    }

    if (s == null)
    {
    }

    if (s is null)
    {
    }

    if (s == "")
    {
    }

    if (s.length)
    {
    }

    return 0;
}

void main()
{
        static x = foo();
}

If s is initialized to a literal, only the last two if's compile successfully.


-- 

July 26, 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1375


smjg@iname.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |smjg@iname.com
           Keywords|                            |rejects-valid




------- Comment #1 from smjg@iname.com  2007-07-25 20:21 -------
When filing bugs, please include the error messages rather than merely stating that something doesn't compile.

bz1375.d(30): Error: cannot evaluate foo() at compile time


-- 

July 26, 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1375





------- Comment #2 from samukha@voliacable.com  2007-07-26 02:49 -------
I wish the error message was informative enough to be worth writing. Anyway, thanks for pointing that out.


-- 

July 02, 2008
http://d.puremagic.com/issues/show_bug.cgi?id=1375


wbaxter@gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|CTFE fails for null arrays  |CTFE fails for null strings
                   |                            |and arrays




------- Comment #3 from wbaxter@gmail.com  2008-07-02 00:08 -------
Another example of probably same bug:

char[] copy(char[] x)
{
    char[] ret;
    foreach(c; x) {
        ret ~= c;
    }
    return ret;
}
pragma(msg, copy(``));


Error:
test_ext.d(83): pragma msg string expected for message, not 'null'

Can work around by changing
    char[] ret;
to
    char[] ret = ``;


-- 

January 07, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=1375





------- Comment #4 from clugdbug@yahoo.com.au  2009-01-07 08:32 -------
This works for me in 1.039.


-- 

April 06, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=1375


clugdbug@yahoo.com.au changed:

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




------- Comment #5 from clugdbug@yahoo.com.au  2009-04-06 03:02 -------
This works in DMD2.027 and DMD1.042.


--