www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 7271] New: Calling struct.init causes a memory allocation.

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

           Summary: Calling struct.init causes a memory allocation.
           Product: D
           Version: D2
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: code benjamin-thaut.de


--- Comment #0 from Benjamin Thaut <code benjamin-thaut.de> 2012-01-11 09:03:33
PST ---
struct MemoryBlockInfo
{
  size_t size;
  long[10] backtrace;
  int backtraceSize;

  this(size_t size)
  {
    this.size = size;
  }
}

int main(string[] argv)
{
  MemoryBlockInfo info;
  info = MemoryBlockInfo.init; //array allocation here
} 

This allocation seems totaly unneccesary. Also TypeInfo.init should return a
immutable(void)[] instead of a void[] as it seems totaly illogical to modify
the data retreived by TypeInfo.init.

This is especially critical when working without a GC because one is not able
to free the allocated memory for the array as the allocation gets generated by
the compiler.

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