Thread overview |
---|
January 06, 2009 [Issue 2559] New: enum doesn't work properly for invariant arrays | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=2559 Summary: enum doesn't work properly for invariant arrays Product: D Version: 2.022 Platform: PC OS/Version: Windows Status: NEW Keywords: wrong-code Severity: normal Priority: P2 Component: DMD AssignedTo: bugzilla@digitalmars.com ReportedBy: 2korden@gmail.com void foo(int offset) { enum i1 = [1, 2, 3]; invariant(int[]) i2 = [1, 2, 3]; writefln(i1[offset]); // prints garbage writefln(i2[offset]); // prints valid value } foo(0); Test run result: ------- 4315632 1 -- |
April 08, 2009 [Issue 2559] bad code generation for enum arrays | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=2559 clugdbug@yahoo.com.au changed: What |Removed |Added ---------------------------------------------------------------------------- Severity|normal |blocker Keywords| |accepts-invalid Priority|P2 |P1 Summary|enum doesn't work properly |bad code generation for enum |for invariant arrays |arrays ------- Comment #1 from clugdbug@yahoo.com.au 2009-04-08 02:08 ------- I've changed the title, since I believe this bug is extremely serious. Simpler example: -------------- enum ubyte[4] a = [5,6,7,8]; void main() { int x=3; assert(a[x]==7); } ----------- Interestingly, compiling with -O gives bug.d(7): Error: variable a used before set which shows that the initializer is being ignored. My opinion is that that's correct -- the only reason you're using an enum is so that it doesn't appear in the executable! Using a variable to index into the enum is arguably equivalent to taking the address of the enum, and should therefore be illegal -- use "immutable" instead. -- |
April 08, 2009 [Issue 2559] bad code generation for enum arrays | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=2559 clugdbug@yahoo.com.au changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |gide@nwawudu.com ------- Comment #2 from clugdbug@yahoo.com.au 2009-04-08 02:09 ------- *** Bug 2792 has been marked as a duplicate of this bug. *** -- |
April 08, 2009 [Issue 2559] bad code generation for enum arrays | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=2559 ------- Comment #3 from clugdbug@yahoo.com.au 2009-04-08 02:20 ------- Possible the same as bug 1884. -- |
October 27, 2009 [Issue 2559] bad code generation for enum arrays | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=2559 Don <clugdbug@yahoo.com.au> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |clugdbug@yahoo.com.au Severity|blocker |critical -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
October 20, 2010 [Issue 2559] bad code generation for enum arrays | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=2559 Don <clugdbug@yahoo.com.au> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |FIXED --- Comment #4 from Don <clugdbug@yahoo.com.au> 2010-10-19 23:54:24 PDT --- This was fixed in DMD2.031. The reduced test case was wrong! Should have been int x=2; -- 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