Bug 7752 – Static array .init is actually .init of the array element type, not the array.
Status
RESOLVED
Resolution
WORKSFORME
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-03-22T08:34:00Z
Last change time
2015-06-09T05:11:48Z
Assigned to
nobody
Creator
david.eckardt
Comments
Comment #0 by david.eckardt — 2012-03-22T08:34:02Z
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.
Comment #1 by monarchdodra — 2012-09-14T03:12:46Z
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?
Comment #2 by monarchdodra — 2012-10-05T15:43:31Z
Well, this was either invalid, or fixed, but it works now anyways. Closing as resilved/worksforme