D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 6565 - out 2D fixed-sized array
Summary: out 2D fixed-sized array
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P2 normal
Assignee: No Owner
URL:
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2011-08-27 19:26 UTC by bearophile_hugs
Modified: 2015-06-17 21:04 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description bearophile_hugs 2011-08-27 19:26:14 UTC
void foo(out int[2][2] m) {}
void main() {
    int[2][2] mat = [[1, 2], [3, 4]];
    foo(mat);
}


DMD 2.055head gives:

test.d(1): Error: cannot implicitly convert expression (0) of type int to int[2u][]
Comment 1 SomeDude 2012-04-27 10:03:12 UTC
What is the problem ? I think this is an appropriate error message.
Comment 2 Stewart Gordon 2012-04-28 04:40:58 UTC
(In reply to comment #1)
> What is the problem ? I think this is an appropriate error message.

How do you work that out???
Comment 3 SomeDude 2012-04-28 04:58:34 UTC
(In reply to comment #2)
> (In reply to comment #1)
> > What is the problem ? I think this is an appropriate error message.
> 
> How do you work that out???

I may be completely wrong, but I would imagine {} is equivalent to {return;} which by default returns an int ?? I agree it's a bit fetched, but the test code too.
Comment 4 Stewart Gordon 2012-04-28 05:09:18 UTC
(In reply to comment #3)
> I may be completely wrong, but I would imagine {} is equivalent to 
> {return;} which by default returns an int ??

Where do you get that idea from?

return;

returns void.  As does reaching the end of a function with void return type without hitting a return statement.

Back to your original comment, where do you see a 0 in the reporter's code, let alone an attempt to convert one to an int[2u][]?
Comment 5 Kenji Hara 2015-01-09 09:24:45 UTC
Fixed in 2.065.