Bug 11105 – Error on struct with multidimentional static array initialization from its element
Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-09-22T23:12:00Z
Last change time
2013-10-03T13:58:30Z
Keywords
pull, rejects-valid
Assigned to
nobody
Creator
verylonglogin.reg
Comments
Comment #0 by verylonglogin.reg — 2013-09-22T23:12:17Z
This used to compile:
---
struct S
{ int[2][1] a21; }
void main()
{
S s = S([1, 2]); // Error: cannot implicitly convert expression ([1, 2]) of type int[] to int[2u][1u]
}
---
Not sure about validity of the issue as documentation doesn't provide exact implicit conversions on struct initialization.
Comment #1 by clugdbug — 2013-09-23T03:38:45Z
> Not sure about validity of the issue as documentation doesn't provide exact
implicit conversions on struct initialization.
I'm not sure either.
struct S
{
int [2][1] xx = [1, 2];
}
prints:
test.d(3): Error: array initializer has 2 elements, but array length is 1.
So the struct literal behaviour is consistent with that. Yet,
void main()
{
int [2][1] xx = [1, 2];
}
is accepted. I think the difference in behaviour is hard to justify.