[gecode-users] Access Violation when temporary BoolVarAgs looses scope.

Uwe Nowak uwe.nowak at itwm.fraunhofer.de
Thu Jun 27 12:57:22 CEST 2013


Hello!

I am getting an access violation creating a custom Space and boiled it down
to the following minimal example.
When the tmp array is destroyed (as it gets out of scope) I get an access
violation.
Visual Studio 10, 32bit (on a 64 bit machine)

Did I missunderstand the concept of temporary variables? If all variables
are instance variables, everything works fine.
Interesting enough, it also works if tmp  has a length less or equal to 16.


class DummySpace : public Gecode::Space {
public:
  DummySpace(bool share, DummySpace& other)  : Space(share, other) { }

  DummySpace() { 
    {
      Gecode::BoolVarArgs tmp(*this, 17, 0, 1);
      for(int j = 0; j<tmp.size(); ++j) rel(*this, tmp[j] == 1);
    } //tmp gets out of scope
    std::cout << "Never executed!" << std::endl;
  }

  DummySpace* copy(bool share) {
    return new DummySpace(share, *this);
  }
};


Thank you for your support,
Uwe




More information about the users mailing list