Thread overview |
---|
July 19, 2008 [Issue 2237] New: string mixin + const array = array literal constructed upon every use (??!?!) | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=2237 Summary: string mixin + const array = array literal constructed upon every use (??!?!) Product: D Version: 1.031 Platform: PC OS/Version: All Status: NEW Keywords: wrong-code Severity: normal Priority: P2 Component: DMD AssignedTo: bugzilla@digitalmars.com ReportedBy: jarrett.billingsley@gmail.com Oh, DMDFE, what am I ever going to do with you. const int[] arr = mixin("[5, 6]"); void main() { int f = 0; int y = arr[f]; // make sure it's a non-constant index } If you look at the generated code, it actually inserts the dynamic array literal [5, 6] EVERYWHERE 'arr' IS USED. So it's more like you do: int y = [5, 6][f]; If you change the declaration of 'arr' to be a mixin declaration instead: mixin("const int[] arr = [5, 6];"); It actually puts the array in the static data segment and accesses it from there, like it should. -- |
February 02, 2012 [Issue 2237] string mixin + const array = array literal constructed upon every use (??!?!) | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=2237 yebblies <yebblies@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |yebblies@gmail.com Resolution| |DUPLICATE --- Comment #1 from yebblies <yebblies@gmail.com> 2012-02-02 20:49:34 EST --- *** This issue has been marked as a duplicate of issue 2356 *** -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
February 09, 2012 [Issue 2237] string mixin + const array = array literal constructed upon every use (??!?!) | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=2237 Denis <verylonglogin.reg@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |REOPENED CC| |verylonglogin.reg@gmail.com Resolution|DUPLICATE | --- Comment #2 from Denis <verylonglogin.reg@gmail.com> 2012-02-09 11:26:02 MSK --- Is it really a duplicate? issue 2356 doesn't mention string mixins or any other initializer dependencies. Why --- const int[] arr = mixin("[5, 6]"); --- behaves differ from --- mixin("const int[] arr = [5, 6];"); --- ? -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
February 09, 2012 [Issue 2237] string mixin + const array = array literal constructed upon every use (??!?!) | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=2237 --- Comment #3 from yebblies <yebblies@gmail.com> 2012-02-10 02:05:57 EST --- Hmm, I think I must have put the wrong bug number in. I think this is a duplicate of the D1 version of bug 2414. Now if only I could find the actual bug... (I can only find that one because I know it has 'yum' in the title.) Glad somebody is checking. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
Copyright © 1999-2021 by the D Language Foundation