id summary reporter owner description type status milestone component version severity resolution keywords cc 1990 xpressive: passing temporary regex to sregex_token_iterator causes runtime assertion jesse@… Eric Niebler "This program suprises me by causing a runtime assertion: {{{ #include #include using namespace boost::xpressive; int main() { std::string x(""a\tb\tc""); sregex_token_iterator cur(x.begin(), x.end(), as_xpr(""\t""), -1), end; for(; cur != end; ++cur) ; } }}} ...the assertion: {{{ suprise: /usr/local/include/boost-1_35/boost/xpressive/detail/utility/tracking_ptr.hpp:196: void boost::xpressive::detail::enable_reference_tracking::release() [with Derived = boost::xpressive::detail::regex_impl<__gnu_cxx::__normal_iterator, std::allocator > > >]: Assertion `0 < this->cnt_' failed. Aborted }}} Changing the declarations like this causes it to work as I expect: {{{ sregex tab_delim(as_xpr(""\t"")); sregex_token_iterator cur(x.begin(), x.end(), tab_delim, -1), end; }}} ...maybe there's some ""temporary"" magic happening, or that I was just plain doing something I shouldn't have been doing (silly me!), or both? [Note: Boost 1.35, OpenSuSE 10.3, g++ 4.1.2] Eric Niebler's reply of 4/6/2008: {{{ Interesting. Currently the regex iterators hold a (bare) pointer to the regex to be used. If you pass in a temporary regex, it'll obviously not live long enough. It wouldn't be hard to make the regex iterators hold a reference count to the regex impl, which would make your code work. The down-side would be that copying regex iterators (a common operation?) would be more expensive. }}} " Bugs closed Boost 1.36.0 xpressive Boost 1.35.0 Problem fixed