[Issue 5997] New: Static arrays with 0 length accepted by compiler

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri May 13 19:29:17 PDT 2011


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

           Summary: Static arrays with 0 length accepted by compiler
           Product: D
           Version: unspecified
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Keywords: accepts-invalid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: andrej.mitrovich at gmail.com


--- Comment #0 from Andrej Mitrovic <andrej.mitrovich at gmail.com> 2011-05-13 19:25:14 PDT ---
Is there a use case for 0-length static arrays?

If there's not a use-case, then this should probably be a compiler error:

int[0] logs;  // <- disallow this

void main()
{
    logs = [4];
}

The assignment statement causes a linker error (if you comment it out you won't
get any linker errors):
/+
test.obj(test)  Offset 002DFH Record Type 009D
 Error 16: Index Range
--- errorlevel 1
+/

-- 
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