www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 7752] New: Static array .init is actually .init of the array element type, not the array.

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

           Summary: Static array .init is actually .init of the array
                    element type, not the array.
           Product: D
           Version: D1 & D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: david.eckardt sociomantic.com



08:34:02 PDT ---
Let T be a type and n a size_t constant, then T[n].init is the same as T.init.

This causes the program code

---
    {
        int[5] x;

        if (x == x.init) { /* ... */ }
    }
---

to be rejected with the compiler error message "Error: incompatible types for
((x) == (0)): 'int[5u]' and 'int'", whereas

---
    static assert(x.init == x[0].init);
---

passes successfully.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 22 2012
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7752


monarchdodra gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |monarchdodra gmail.com



Just executed this:

--------
void main()                       // 1
{                                 // 2
    int[5] x;                     // 3
                                  // 4
    if (x == x.init) { }          // 5 Code that should be legal
    if (x.init == x[0].init) { }  // 6 Code that is actually illegal
}                                 // 7
--------

And it produces:

--------
main.d(6): Error: incompatible types for (([0,0,0,0,0]) == (0)): 'int[5u]' and
'int'
--------

So it looks like the issue is fixed. Anybody know which pull fixed this, or
should I just close?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 14 2012
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7752


monarchdodra gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |WORKSFORME



Well, this was either invalid, or fixed, but it works now anyways. Closing as
resilved/worksforme

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