[mlpack] Question about Armadillo

Kirill Mishchenko ki.mishchenko at gmail.com
Tue Jun 27 00:10:06 EDT 2017


Hi mlpack community!

I’m not sure it is a right place to ask a question that I want to ask, but, anyway, maybe somebody will be eager to answer. Otherwise, just ignore this message.

I have encountered some unexpected behaviour with the Armadillo library. The following code snippet works as expected:

template<typename T>
void f(const T& arg)
{
  arma::mat m = arg;
}

BOOST_AUTO_TEST_CASE(RefTest)
{
  f(arma::join_rows(arma::zeros(2).t(), arma::zeros(2).t()));
}

But if I run the following

BOOST_AUTO_TEST_CASE(RefTest2)
{
  const auto& ref = arma::join_rows(arma::zeros(2).t(), arma::zeros(2).t());
  arma::mat m = ref;
}

I get this error:

unknown location:0: fatal error: in "ArmaExtendTest/RefTest2": memory access violation at address: 0x00000000: no mapping at fault address

Surprisingly, if run the following code snippet

BOOST_AUTO_TEST_CASE(RefTest3)
{
  const auto& ref = arma::join_rows(arma::zeros(2), arma::zeros(2));
  arma::mat m = ref;
}

everything is ok again.

Are there any thoughts why I observe such behaviour?

Best regards,

Kirill Mishchenko



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://knife.lugatgt.org/pipermail/mlpack/attachments/20170627/e70e52d2/attachment.html>


More information about the mlpack mailing list