Bug 4737 – typeid doesn't work for scoped enum with initializer

Status
RESOLVED
Resolution
WORKSFORME
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
Other
OS
Windows
Creation time
2010-08-26T14:34:00Z
Last change time
2013-02-09T22:20:38Z
Assigned to
nobody
Creator
andrej.mitrovich

Comments

Comment #0 by andrej.mitrovich — 2010-08-26T14:34:39Z
module test; import std.stdio; unittest { enum X { A = 3, B, C } X x; write(typeid(x)); write(typeid(X)); } void main() { } Error 42: Symbol Undefined _D4test11__unittest1FZv1X6__initZ Sometimes it will compile, but then the app crashes and I get an access violation message in console.
Comment #1 by andrej.mitrovich — 2011-05-20T19:11:53Z
typeid works with scoped enums, but not with ones that have an initializer.
Comment #2 by lovelydear — 2012-04-21T15:29:34Z
Compiles and runs fine on 2.059 Win32
Comment #3 by andrej.mitrovich — 2012-04-21T15:31:23Z
(In reply to comment #2) > Compiles and runs fine on 2.059 Win32 No. Please remember to compile with -unittest.
Comment #4 by lovelydear — 2012-04-21T16:06:36Z
Oups, didn't see it. I guess it's time to go to bed... :)
Comment #5 by andrej.mitrovich — 2012-04-21T16:15:22Z
(In reply to comment #4) > Oups, didn't see it. I guess it's time to go to bed... :) No worries. I was on a closing closing streak once ages ago and I ended up accidentally closing a bunch of DMD 1.x bugs because I couldn't recreate them in 2.x (I wasn't looking at the Version field above). They all had to be reverted to open again. :)
Comment #6 by lovelydear — 2012-12-31T12:30:02Z
http://dpaste.dzfl.pl/fork/7f894621 2.060 DMD: compilation failure GDC: compiles and runs but no output LDC: compiles and runs with the following output c19.__unittest1.X c19.__unittest1.X (c19 being the execution instance)
Comment #7 by andrej.mitrovich — 2012-12-31T13:33:48Z
(In reply to comment #6) > GDC: compiles and runs but no output DPaste might be using -unittest by mistake instead of -funittest for GDC. Run it with `gdc -m32 -funittest test.d && a.exe` and you'll see the output.
Comment #8 by andrej.mitrovich — 2013-02-09T22:20:38Z
Resolved in 2.062 git-head by a pull for another report (dupe of this one).