Bug 8533 – Postfix and prefix declarations of static multidimensional arrays aren't equivalent
Status
RESOLVED
Resolution
INVALID
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2012-08-10T10:16:00Z
Last change time
2012-08-10T11:30:16Z
Assigned to
nobody
Creator
FatalError
Comments
Comment #0 by FatalError — 2012-08-10T10:16:19Z
I found this in v2.059 and v2.060.
Consider these 2 programs:
Pre:
void main()
{
int m[3][2];
foreach(i;0..3)
{
m[0][i]=0;
m[1][i]=1;
}
}
Post:
void main()
{
int [3][2]m;
foreach(i;0..3)
{
m[0][i]=0;
m[1][i]=1;
}
}
They only differ in the declaration of m.
Pre throws a range violation, but Post does not. This is a bug, because the documentation for rectangular arrays claims
int [3][2]m;
int m[3][2];
to be equivalent declarations.
Comment #1 by timon.gehr — 2012-08-10T10:33:29Z
The documentation doesn't seem to state the equivalence of
int[3][2] m;
int m[3][2];
and indeed the declarations are not equivalent.
int[3][2] m;
int m[2][3];
would be equivalent.
If there is a place in the documentation that does state the first
equivalence, please file a bug against the documentation.