Bug 2792 – Enum manifest constants and string produces errors
Status
RESOLVED
Resolution
DUPLICATE
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2009-04-03T13:48:00Z
Last change time
2015-06-09T01:18:23Z
Keywords
wrong-code
Assigned to
bugzilla
Creator
gide
Comments
Comment #0 by gide — 2009-04-03T13:48:04Z
Using const, static const, auto, immutable instead of enum makes it work.
Might be related to BUG 1884.
import std.stdio;
void main()
{
enum members = ["foo", "bar"];
for (uint i=0; i<members.length; i++) {
writefln(members[i]);
}
}
C:> dmd test.d
C:> test
object.Error: Access Violation
std.encoding.EncodingSchemeASCII ðæB ANSI_X3.4-1968 ♫ ÆB ANSI_X3.
4-1986 ♫ ↑ÆB ASCII ♣ 0ÆB IBM367 ♠ @ÆB ISO646-US PÆB I
SO_646.irv:1991 ► hÆB US-ASCII êÆB cp367 ♣ áÆB csASCIIiso-i
Comment #1 by gide — 2009-04-03T14:23:17Z
Another example.
import std.stdio;
void main()
{
enum members = ["foo", "bar"];
writefln(members[0]); // works fine
writefln(members[1]); // works fine
for (uint i=0; i<2; i++) {
writefln(members[i]); // ERROR
}
}
Comment #2 by clugdbug — 2009-04-08T02:09:52Z
*** This bug has been marked as a duplicate of 2559 ***