www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 3951] New: [CTFE] With a fixed-size array

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

           Summary: [CTFE] With a fixed-size array
           Product: D
           Version: 2.041
          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-03-13 04:55:46 PST ---
I can't invent a good name for this bug.
This looks valid CTFE code, but it doesn't compile:


int foo1(int n)(int[n] array) {
    foreach (el; array) {}
    return 0;
}
int foo2(int n)(int[n] array) {
    for (int i; i < n; i++) {
        int el = array[i];
    }
    return 0;
}
int spam() {
    int[1] array;
    enum int i1 = foo1(array);
    enum int i2 = foo2(array);
    return 0;
}
enum int r = spam();
void main() {}



Errors produced:
test.d(12): Error: cannot cast int to int[]
test.d(12): Error: cannot cast int to int[]
test.d(12): Error: cannot cast int to int[]
test.d(13): Error: cannot evaluate foo1(array) at compile time
test.d(13): Error: cannot evaluate foo1(array) at compile time

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 13 2010
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3951


Don <clugdbug yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |clugdbug yahoo.com.au
         Resolution|                            |FIXED


--- Comment #1 from Don <clugdbug yahoo.com.au> 2010-03-26 06:58:17 PDT ---
This was fixed in DMD2.042.

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