Bug 5678 – new enum struct re-allocated at compile time

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
Other
OS
Windows
Creation time
2011-03-01T15:07:00Z
Last change time
2011-04-16T22:26:16Z
Keywords
wrong-code
Assigned to
nobody
Creator
bearophile_hugs

Comments

Comment #0 by bearophile_hugs — 2011-03-01T15:07:20Z
DMD 2.052, this gives an Assertion failure: struct Foo { this(int) {} } enum Foo* f = new Foo(0); void main() { assert(f == f); // Assertion failure } In my opinion this needs to become a compile-time error, or the assert needs to pass. Enum associative arrays have a similar problem. ------------------ The asm: _D4test3Foo6__ctorMFNciZS4test3Foo comdat enter 4,0 leave ret 4 __Dmain comdat L0: push 1 mov EAX,offset FLAT:_D20TypeInfo_PS4test3Foo6__initZ push EAX call near ptr __d_newarrayT add ESP,8 push 0 mov EAX,EDX call near ptr _D4test3Foo6__ctorMFNciZS4test3Foo push EAX push 1 mov ECX,offset FLAT:_D20TypeInfo_PS4test3Foo6__initZ push ECX call near ptr __d_newarrayT add ESP,8 push 0 mov EAX,EDX call near ptr _D4test3Foo6__ctorMFNciZS4test3Foo mov EDX,EAX pop EAX cmp EAX,EDX je L44 mov EAX,6 call near ptr _D4test8__assertFiZv L44: xor EAX,EAX ret _D4test8__assertFiZv comdat L0: enter 4,0 push EAX mov ECX,offset FLAT:_D4test12__ModuleInfoZ push ECX call near ptr __d_assertm leave ret
Comment #1 by clugdbug — 2011-04-15T22:34:17Z
Comment #2 by bearophile_hugs — 2011-04-16T06:46:24Z
Is the same problem with associative arrays in another bug report?
Comment #3 by clugdbug — 2011-04-16T22:26:16Z
(In reply to comment #2) > Is the same problem with associative arrays in another bug report? The general bug, which includes AAs, was fixed with this commit: https://github.com/donc/dmd/commit/fc67046cf1e66182d959309fb15ef9e2d4c266b9 The only thing which was unique to this one is the use of 'new'.