diff --git a/eo/src/eoInit.h b/eo/src/eoInit.h index 88bc98999..9146311fa 100644 --- a/eo/src/eoInit.h +++ b/eo/src/eoInit.h @@ -120,7 +120,7 @@ class eoInitFixedLength: public eoInitWithDim virtual void operator()(EOT& chrom) { - chrom.resize(this->_dimension); + chrom.resize(this->dimension()); std::generate(chrom.begin(), chrom.end(), _generator); chrom.invalidate(); } diff --git a/eo/src/eoPerf2Worth.h b/eo/src/eoPerf2Worth.h index f7d08f512..02c065c2e 100644 --- a/eo/src/eoPerf2Worth.h +++ b/eo/src/eoPerf2Worth.h @@ -69,7 +69,15 @@ public: std::sort(indices.begin(), indices.end(), compare_worth(value())); eoPop tmp_pop; - tmp_pop.resize(_pop.size()); + // tmp_pop.resize(_pop.size()); // NOPE + // Using resize to create a tmp pop would require empty constructors on EOT, + // which is a recipe for having out-of-bounds accesses on EOT which are containers + // and default-initialize at size of zero. + // Thus, we copy the existing pop instead, which should no be a problem + // as we later iterate over all the individuals anyway. + // -- JD + std::copy(_pop.begin(), _pop.end(), std::back_inserter(tmp_pop)); + std::vector tmp_worths(value().size()); for (i = 0; i < _pop.size(); ++i)