www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Bug 139] New: Forward reference of enum type doesn't work or crashes compiler

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/bugzilla/show_bug.cgi?id=139

           Summary: Forward reference of enum type doesn't work or crashes
                    compiler
           Product: D
           Version: 0.157
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Keywords: ice-on-valid-code, rejects-valid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: smjg iname.com


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.


-- 
May 13 2006
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/bugzilla/show_bug.cgi?id=139


bugzilla digitalmars.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED




------- Comment #1 from bugzilla digitalmars.com  2006-06-04 22:15 -------
Fixed in DMD 0.160


-- 
Jun 04 2006