Sunday, 15 January 2012

d - Object.Error: Access Violation when printing result of std.algorithm.cartesianProduct -


I am using DMD 2.062 for x86.

  module testing; Private anonym test1 {one, two, three,} private enum test2 {one, two, three,} auto CT = cartesian product ([EnumMembers! Test1], [EnumMembers! Test2]); Integrate {import std.stdio; Agram (n, m; whistle) {Shelter (n, "", m); }}   

This program prints:

  one two one three one   

then an access violation Error is thrown whether I am using cartesianProduct incorrectly or is this a bug in the function?

Maybe a small part of both, maybe. The point here is that an attempt is made to evaluate ct at compile time and produces the range used in run-time, I think CTF or Cartesian products expect such a scenario. Does not do anything bad that involves the use of invalid memory; I think that should is either work, or a compile-time error, but it will not help you And bug related to Tracker.

Here's what the matter is, however, if you move the unit-test body or static it () to the module constructor to start ct Everything will work, what do you miss, does not support the initialization of global variables when the D program starts. The value assigned to Global is always assessed at compile-time, which often "just works", is often the result of an error in collection-time (if CTRL-enabled is not an initialization) and in this case there is strange behavior :)

This code is what you want:

  Auto Test 1 member = [EnumMembers! Test1]; Auto Test 2 Members = [EnumMembers! Test2]; Nickname CT = typef (cartesian product (test 1 member, test 2 member)); Whistle whistle; Stable it () {whistle = cartesian product (test 1 member, test 2member); }   

In general, the relation between each other in run-time data for complex-time data and complex time is very difficult as the current de-front-end implementation in the form of arrays or associative arrays. And a lot of attention is needed

No comments:

Post a Comment