[Issue 6174] New: Initialize const fixed-size array in constructor

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Jun 18 04:36:38 PDT 2011


http://d.puremagic.com/issues/show_bug.cgi?id=6174

           Summary: Initialize const fixed-size array in constructor
           Product: D
           Version: D2
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: bearophile_hugs at eml.cc


--- Comment #0 from bearophile_hugs at eml.cc 2011-06-18 04:31:54 PDT ---
This program shows that you are allowed to initialize a single const char
inside static this() and struct constructor, but you are not allowed to
initialize the items of a char array:


const char gc;
const char[1] ga;
static this() {
    gc = 'a';    // OK
    ga[0] = 'a'; // line 5, Err
}
struct Foo {
    const char cc;
    const char[1] array;
    this(char c) {
        cc = c;       // OK
        array = [c];  // line 12, Err
        array[0] = c; // line 12, Err
    }
}
void main() {}


DMD 2.053:
temp.d(5): Error: ga[0] isn't mutable
temp.d(12): Error: slice this.array[] is not mutable
temp.d(13): Error: this.array[0] isn't mutable

I'd like to initialize the arrays too.

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


More information about the Digitalmars-d-bugs mailing list