digitalmars.D.bugs - [Issue 2559] New: enum doesn't work properly for invariant arrays
- d-bugmail puremagic.com (26/26) Jan 06 2009 http://d.puremagic.com/issues/show_bug.cgi?id=2559
- d-bugmail puremagic.com (28/28) Apr 08 2009 http://d.puremagic.com/issues/show_bug.cgi?id=2559
- d-bugmail puremagic.com (8/8) Apr 08 2009 http://d.puremagic.com/issues/show_bug.cgi?id=2559
- d-bugmail puremagic.com (4/4) Apr 08 2009 http://d.puremagic.com/issues/show_bug.cgi?id=2559
- d-bugmail puremagic.com (9/9) Oct 27 2009 http://d.puremagic.com/issues/show_bug.cgi?id=2559
- d-bugmail puremagic.com (12/12) Oct 19 2010 http://d.puremagic.com/issues/show_bug.cgi?id=2559
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
--
Jan 06 2009
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
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.
--
Apr 08 2009
http://d.puremagic.com/issues/show_bug.cgi?id=2559
clugdbug yahoo.com.au changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |gide nwawudu.com
*** Bug 2792 has been marked as a duplicate of this bug. ***
--
Apr 08 2009
http://d.puremagic.com/issues/show_bug.cgi?id=2559 Possible the same as bug 1884. --
Apr 08 2009
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: -------
Oct 27 2009
http://d.puremagic.com/issues/show_bug.cgi?id=2559
Don <clugdbug yahoo.com.au> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |FIXED
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: -------
Oct 19 2010









d-bugmail puremagic.com 