segmentation fault in c++ on linux
<p>I am getting a segmentation fault in very unlikely function called expired(ptime). As you can see it is expecting a reference variable, so it cannot be null. The variable cutoff is assigned in the constructor called CheckExpiry. Any ideas what would cause one line function expired to cause segmentation fault?</p>

<pre><code>class CheckExpiry
{
public:
boost::posix_time::ptime cutoff;

CheckExpiry(long ttlMs)
{
 cutoff =  boost::posix_time::microsec_clock::universal_time() - boost::posix_time::milliseconds(ttlMs)
}

bool expired(const boost::posix_time::ptime&amp; x) const
{
  return (x &lt; cutoff);
}
};
</code></pre>

<p>The backtrace shows the following. Is it possible that calling code is causing the segmentation fault?</p>

<pre>
Program terminated with signal 11, Segmentation fault.
</pre>

<pre>
#0  0x00007f6909051564 in CheckExpiry::expired (this=0x7f6902b19aa0, x=...)
</pre>

<p>Update:
The calling code looks like below. </p>

<pre><code>timeList is simply list&lt;boost::posix_time::ptime&gt;

CheckExpiry e(getPeriodMs());
return timeList.size() - count_if
(timeList.begin(), timeList.end(), boost::bind(&amp;CheckExpiry::expired,&amp;e,_1));
</code></pre>
