digitalmars.D.bugs - [Issue 10423] New: built-in arrays being overwritten
- d-bugmail puremagic.com (45/45) Jun 20 2013 http://d.puremagic.com/issues/show_bug.cgi?id=10423
- d-bugmail puremagic.com (22/22) Jun 20 2013 http://d.puremagic.com/issues/show_bug.cgi?id=10423
http://d.puremagic.com/issues/show_bug.cgi?id=10423 Summary: built-in arrays being overwritten Product: D Version: unspecified Platform: All OS/Version: All Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: nobody puremagic.com ReportedBy: iteronvexor gmail.com // GNU/Linux 64-bit // DMD 2.063 This is as far as I could narrow it down. ------------8<------------8<------------ import std.stdio; struct S(size_t M, size_t N) { double[] _data = new double[M*N]; alias _data this; this(double[M*N] data...) pure nothrow { _data[] = data[]; } } unittest { auto m1 = S!(4,4)(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1); auto m2 = S!(2,2)(1,1,1,1); auto m3 = S!(2,3)(1,1,1,1,1,1); auto m4 = S!(3,2)(1,1,1,1,1,1); auto m6 = S!(3,3)(1,1,1,1,1,1,1,1,1); auto m9 = S!(4,4)(4,0,0,0,0,0,2,0,0,1,2,0,1,0,0,1); assert(S!(2,2)(1,1,1,1)._data == [1,1,1,1]); writeln(m1); } void main() { } ------------>8------------>8------------ Expected: [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ,1 ,1 ,1 ,1] I get: [4, 0, 0, 0, 0, 0, 2, 0, 0, 1, 2, 0, 1, 0, 0, 1] -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jun 20 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10423 Nils <nilsbossung googlemail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |nilsbossung googlemail.com Resolution| |DUPLICATE --- Reduction shows that it's a duplicate of issue 2947: struct S { double[] _data = new double[1]; this(int ignored) {} } void main() { assert(S()._data !is S()._data); // passes assert(S(0)._data !is S(0)._data); // fails assert((new S)._data !is (new S)._data); // fails } *** This issue has been marked as a duplicate of issue 2947 *** -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jun 20 2013