Vladimir Marek <Vladimir.Marek@Oracle.COM> writes: >> It's okay to use the result of .c_str() as long as the string object >> stays in scope, and none of the non-const member functions are >> called. Here, I think the problem is that TermIterator's overloaded >> operator*() returns a string object within the if block's scope, and it >> goes immediately out of scope. You could check this by adding > > Right, I overlooked that TermIterator creates temporary string (if I > understand you correctly). > >> fine too. > > I would prefer my change as it avoids creating another std::string. At > least I think. Would you mind updating your commit message to reflect the best guesses from this discussion? d