digitalmars.D.bugs - [Issue 6797] New: Fake changes to enum array of array
- d-bugmail puremagic.com (29/29) Oct 08 2011 http://d.puremagic.com/issues/show_bug.cgi?id=6797
- d-bugmail puremagic.com (32/32) May 01 2012 http://d.puremagic.com/issues/show_bug.cgi?id=6797
- d-bugmail puremagic.com (26/26) Dec 02 2012 http://d.puremagic.com/issues/show_bug.cgi?id=6797
http://d.puremagic.com/issues/show_bug.cgi?id=6797 Summary: Fake changes to enum array of array Product: D Version: D2 Platform: x86 OS/Version: Windows Status: NEW Keywords: accepts-invalid Severity: normal Priority: P2 Component: DMD AssignedTo: nobody puremagic.com ReportedBy: bearophile_hugs eml.cc --- Comment #0 from bearophile_hugs eml.cc 2011-10-08 19:17:03 PDT --- Maybe this was reported already, because it looks like a basic bug. This compiles and runs with no errors (DMD 2.056head): void main() { enum int[][] array = [[0, 1], [2, 3]]; foreach (r; array) r[0] *= 10; foreach (ref r; array) r[0] *= 10; assert(array == [[0, 1], [2, 3]]); } This is a big hole. I think the implementation of compile-time constants need a lot of debugging. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Oct 08 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6797 SomeDude <lovelydear mailmetrash.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |lovelydear mailmetrash.com --- Comment #1 from SomeDude <lovelydear mailmetrash.com> 2012-05-01 15:08:48 PDT --- This simpler case actually fails: void main() { enum int[] array = [2, 1]; foreach (r; array){ r *= 10; // should be rejected writeln(array); } foreach (ref r; array){ r *= 10; // should be rejected writeln(array); } assert(array == [20, 10]); } Changing enum to immutable gives the following compilation errors: bug.d(8): Error: variable bug.main.r cannot modify immutable bug.d(12): Error: variable bug.main.r cannot modify const But this void main() { enum int[] array = [2, 1]; array[0] = 5; } is correctly caught by the compiler: bug.d(7): Error: constant [2,1][0] is not an lvalue -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
May 01 2012
http://d.puremagic.com/issues/show_bug.cgi?id=6797 Andrej Mitrovic <andrej.mitrovich gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |andrej.mitrovich gmail.com --- Comment #2 from Andrej Mitrovic <andrej.mitrovich gmail.com> 2012-12-02 10:33:38 PST --- There is no "hole" here, what you get here are separate arrays which are allocated for you wherever you use them. For example: import std.stdio; void main() { enum int[] array = [1, 2]; foreach (i, _; array) writeln(&array[i]); foreach (i, ref _; array) writeln(&array[i]); } Prints: 972FE0 972FD4 972FB0 972FA4 Those are two separate arrays. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Dec 02 2012