www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 10192] New: Fixed size array initialization inconsistency between DeclDefs scope and statement scope

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

           Summary: Fixed size array initialization inconsistency between
                    DeclDefs scope and statement scope
           Product: D
           Version: D2
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Keywords: accepts-invalid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: bearophile_hugs eml.cc


--- Comment #0 from bearophile_hugs eml.cc 2013-05-28 04:39:20 PDT ---
I think it's not OK to accept x3 assignment and refuse the a2 assignment:


struct Foo {
    immutable(char)[4] bar;
}
Foo x1 = { "AA" };            // No error.
immutable(char)[4] a1 = "AA"; // No error.
void main() {
    Foo x2 = { "AA" };        // No error.
    Foo x3 = Foo("AA");       // No error.
    immutable(char)[4] a2 = "AA"; // Error: lengths don't match
                                  // for array copy, 4 = 2
}


Kenji Hara answers:
http://forum.dlang.org/post/akeivrewkkhjuapbngel forum.dlang.org

 This is known static array initializing inconsistency between
 DeclDefs scope and statement scope. I think it is a bug.
See also, where I say that I think all of those five cases should be reported as bugs: http://d.puremagic.com/issues/show_bug.cgi?id=3849 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
May 28 2013