www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 14126] New: GITHEAD - GC seemingly corrupting memory

https://issues.dlang.org/show_bug.cgi?id=14126

          Issue ID: 14126
           Summary: GITHEAD - GC seemingly corrupting memory
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: regression
          Priority: P1
         Component: DMD
          Assignee: nobody puremagic.com
          Reporter: puneet coverify.org

Here is a reduced test. I am making sure that _foo does not get any value other
than 0 or 1. But still when I run this code with the GITHEAD, I get a message:

How can _foo have any other value than 0 or 1?
16777216?? really????
core.exception.InvalidMemoryOperationError (0)

Works fine with release 2.066.1.


import std.stdio;
import std.conv;
class FooBar {
  private Foo[] _foos;
  this() {
    _foos.length = 512;
    foreach(ref foo; _foos)
      foo = Foo(1);
  }
}
struct Foo {
  private uint _foo = 0;
  this(uint foo) {
    assert(foo == 1);
    _foo = foo;
  }
  ~this() {
    if (_foo != 0 && _foo != 1) {
      writeln("How can _foo have any other value than 0 or 1?");
      writeln(_foo, "?? really????");
      assert(false, "Unexpected Value: " ~ _foo.to!string());
    }
  }
}
void main() {
  auto bar = new FooBar();
}

--
Feb 04 2015