Bug 6057 – Problem with defining enum in function

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2011-05-26T05:04:00Z
Last change time
2013-01-20T20:06:40Z
Keywords
link-failure, pull
Assigned to
andrej.mitrovich
Creator
bearophile_hugs

Comments

Comment #0 by bearophile_hugs — 2011-05-26T05:04:59Z
This program compiles and runs with no errors: enum Foo { A=1, B=2 } void main() { Foo[] bar = [cast(Foo)1, cast(Foo)2]; } But moving the enum definition inside the main(): void main() { enum Foo { A=1, B=2 } Foo[] bar = [cast(Foo)1, cast(Foo)2]; } Compiling with DMD 2.053 it gives: OPTLINK (R) for Win32 Release 8.00.12 Copyright (C) Digital Mars 1989-2010 All rights reserved. http://www.digitalmars.com/ctg/optlink.html test.obj(test) Error 42: Symbol Undefined _Dmain3Foo6__initZ
Comment #1 by andrej.mitrovich — 2012-12-19T04:12:06Z
Comment #2 by andrej.mitrovich — 2013-01-10T07:37:02Z
*** Issue 8888 has been marked as a duplicate of this issue. ***
Comment #3 by andrej.mitrovich — 2013-01-17T16:18:07Z
*** Issue 9341 has been marked as a duplicate of this issue. ***
Comment #4 by github-bugzilla — 2013-01-20T20:04:33Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/3fe666756029484ae58c4b7fdb7dfbb6bb99fa8c Fixes Issue 6057 - Nested enum declaration causes linker errors due to missing sections in obj file. https://github.com/D-Programming-Language/dmd/commit/bcb066f49496bc0383fe74663b910578685308a2 Merge pull request #1391 from AndrejMitrovic/Fix6057 Issue 6057 - Nested enum declaration causes linker errors