www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 5678] New: new enum struct re-allocated at compile time

reply d-bugmail puremagic.com writes:
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 puremagic.com
        ReportedBy: bearophile_hugs eml.cc


--- Comment #0 from bearophile_hugs 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: -------
Mar 01 2011
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5678


Don <clugdbug yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |clugdbug yahoo.com.au
         Resolution|                            |FIXED


--- Comment #1 from Don <clugdbug yahoo.com.au> 2011-04-15 22:34:17 PDT ---
Fixed
https://github.com/D-Programming-Language/dmd/commit/47d46bf1364c63df5bb01406db4098c771d701dd

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Apr 15 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5678



--- Comment #2 from bearophile_hugs eml.cc 2011-04-16 06:46:24 PDT ---
Is the same problem with associative arrays in another bug report?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Apr 16 2011
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5678



--- Comment #3 from Don <clugdbug yahoo.com.au> 2011-04-16 22:26:16 PDT ---
(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'. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Apr 16 2011