[Issue 5678] New: new enum struct re-allocated at compile time

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Mar 1 15:10:12 PST 2011


http://d.puremagic.com/issues/show_bug.cgi?id=5678

           Summary: new enum struct re-allocated at compile time
           Product: D
           Version: D2
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Keywords: wrong-code
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: bearophile_hugs at eml.cc


--- Comment #0 from bearophile_hugs at eml.cc 2011-03-01 15:07:20 PST ---
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

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list