www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 4078] New: [CTFE] Failed return of dynamic array item

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

           Summary: [CTFE] Failed return of dynamic array item
           Product: D
           Version: future
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: bearophile_hugs eml.cc


--- Comment #0 from bearophile_hugs eml.cc 2010-04-10 16:41:23 PDT ---
int foo() {
    int[] arr = new int[1];
    return arr[0];
}
static assert(foo() == 0);
void main() {}


dmd 2.043 prints:

test1.d(5): Error: static assert  (null == 0) is not evaluatable at compile
time

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Apr 10 2010
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4078


Don <clugdbug yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch
                 CC|                            |clugdbug yahoo.com.au


--- Comment #1 from Don <clugdbug yahoo.com.au> 2010-05-22 06:56:04 PDT ---
This patch also fixes bug 4052 which has the same root cause.

PATCH (svn 497): interpret.c, NewExp::interpret, line 1579.

       return createBlockDuplicatedArrayLiteral(newtype,
-           newtype->defaultInitLiteral(), lenExpr->toInteger()); 
+            ((TypeArray *)newtype)->next->defaultInitLiteral(),
+            lenExpr->toInteger());

TEST CASES FOR TEST SUITE:

int bug4078() {
    int[] arr = new int[1];
    return arr[0];
}
static assert(bug4078() == 0);

int bug4052() {
    int[] arr = new int[1];
    int s;
    foreach (x; arr)
        s += x;
    foreach (x; arr)
        s += x * x;
    return 4052;
}
static assert(bug4052() == 4052);

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 22 2010
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4078


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla digitalmars.com
         Resolution|                            |FIXED


--- Comment #2 from Walter Bright <bugzilla digitalmars.com> 2010-05-30
16:30:17 PDT ---
http://www.dsource.org/projects/dmd/changeset/507

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