[Issue 6174] Initialize const fixed-size array in constructor

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Oct 8 05:53:45 PDT 2012


http://d.puremagic.com/issues/show_bug.cgi?id=6174



--- Comment #9 from Kenji Hara <k.hara.pg at gmail.com> 2012-10-08 05:35:43 PDT ---
(In reply to comment #8)
> Is this expected? Do you want me to put this in a new bug report?
> 
> struct Foo {
>     int[1] bar;
> }
> const Foo[1] foos;
> static this() {
>     foreach (i; 0 .. foos.length)
>         foos[i].bar[i] = 1; // OK
>     foreach (i, ref f; foos)
>         f.bar[i] = 1; // Error
> }
> void main() {}

Hmm, it's interesting. The accessed memory through the reference 'f' would
specify a part of the constructed fields, and compiler would be able to detect
it in statically.

Please put in a new report.

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


More information about the Digitalmars-d-bugs mailing list