[Issue 11343] [2.064 beta] Error: multiple field initialization
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Oct 30 01:49:55 PDT 2013
http://d.puremagic.com/issues/show_bug.cgi?id=11343
--- Comment #11 from Kenji Hara <k.hara.pg at gmail.com> 2013-10-30 01:49:54 PDT ---
(In reply to comment #10)
> Couldn't the compiler to this dirty trick for me?
> If he found such multiple init case, he could rewrite the code. So that this
> code:
> ----
> this(int x, size_t i) {
> arr[0] = x;
> arr[1] = x + 1;
> arr[i] = x + 2; // which index will be initialized in runtime?
> }
> ----
>
> if rewritten to this:
>
> this(int x, size_t i) {
> Unqual!typeof(arr) __arr = null;
>
> __arr[0] = x;
> __arr[1] = x + 1;
> __arr[i] = x + 2;
>
> this.arr = __arr; /// only _one_ assignment
> }
That would be a bad behavior when the size of arr field is quite big, because
it will silently consume stack memory. I can believe someone will hate it.
--
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