<p>I debugged the above small testing code on Armadillo, and use <code>lldb</code> to see which part causes the problem. Then I found the following infinite loop in <code>random.tcc</code> bared in <code>libstdc++</code>:</p>

<pre><code>   1798         do
   1799           {
   1800         __x = result_type(2.0) * __aurng() - 1.0;
-&gt; 1801         __y = result_type(2.0) * __aurng() - 1.0;
   1802         __r2 = __x * __x + __y * __y;
   1803           }
   1804         while (__r2 &gt; 1.0 || __r2 == 0.0);
(lldb)
</code></pre>

<p>where <code>__x</code> and <code>__y</code> are always -1, so <code>__r2</code> is always 2.</p>

<p>BTW, I am using GCC 6.1.0 compiled by myself, so it is the problem of <code>libstdc++</code>? Sorry, it is not related to MLPACK actually.</p>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">&mdash;<br />You are receiving this because you are subscribed to this thread.<br />Reply to this email directly, <a href="https://github.com/mlpack/mlpack/issues/718#issuecomment-232295010">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe/AJ4bFP_nT47vuVOQc3jH3L_9Nm2DKanLks5qVKXggaJpZM4JIn4Z">mute the thread</a>.<img alt="" height="1" src="https://github.com/notifications/beacon/AJ4bFFGIxpsyNZTYEMHZkgsT01lHac39ks5qVKXggaJpZM4JIn4Z.gif" width="1" /></p>
<div itemscope itemtype="http://schema.org/EmailMessage">
<div itemprop="action" itemscope itemtype="http://schema.org/ViewAction">
  <link itemprop="url" href="https://github.com/mlpack/mlpack/issues/718#issuecomment-232295010"></link>
  <meta itemprop="name" content="View Issue"></meta>
</div>
<meta itemprop="description" content="View this Issue on GitHub"></meta>
</div>