Bug 139 – Forward reference of enum type doesn't work or crashes compiler
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
Windows
Creation time
2006-05-13T16:01:00Z
Last change time
2014-02-15T13:19:41Z
Keywords
ice-on-valid-code, rejects-valid
Assigned to
bugzilla
Creator
smjg
Comments
Comment #0 by smjg — 2006-05-13T16:01:46Z
An enum type cannot be forward-referenced at either global or class scope.
----------
D3DTRANSFORMSTATETYPE D3DTS_WORLDMATRIX(int index) {
return index + 256;
}
enum : D3DTRANSFORMSTATETYPE {
D3DTS_WORLD = 256,
D3DTS_WORLD1,
D3DTS_WORLD2,
D3DTS_WORLD3
}
enum D3DTRANSFORMSTATETYPE {
D3DTS_VIEW = 2,
D3DTS_PROJECTION,
D3DTS_TEXTURE0 = 16,
D3DTS_TEXTURE1,
D3DTS_TEXTURE2,
D3DTS_TEXTURE3,
D3DTS_TEXTURE4,
D3DTS_TEXTURE5,
D3DTS_TEXTURE6,
D3DTS_TEXTURE7, // = 23
D3DTS_FORCE_DWORD = 0xffffffff
}
----------
enum D3DTRANSFORMSTATETYPE is forward referenced
----------
DMD caused an invalid page fault in
module DMD.EXE at 0167:0040b077.
Registers:
EAX=007407cc CS=0167 EIP=0040b077 EFLGS=00010216
EBX=0074b2cc SS=016f ESP=0072fd20 EBP=00740714
ECX=00000000 DS=016f ESI=00740714 FS=4be7
EDX=0072fd0c ES=016f EDI=004b8664 GS=45fe
Bytes at CS:EIP:
8b 11 ff 52 44 59 c3 90 90 51 8b 41 24 8b 48 38
Stack dump:
0074bf2c 0040365d 0074c42c 0074b2cc 00740714 00000002 004a37af 00749894 0074c42c 0074b2cc 00000001 0000000c 0074b2cc 00000000 0043a4eb 0074c42c
----------
I've established that the function triggers the error message, and the use as an enum base triggers the IPF. Various other uses, such as declaring a global variable or constant of the enum type, also trigger the error message. Some of them have tests in DStress under enum_* and forward_reference_*, but none I can find at the moment are for the cases of the above example.