In working with my date/time code I've encountered another problem with Boost. I can reproducibly get lexical_cast to segfault. It happens when a greg_month is lexical_cast to a string. I don't observe this behavior for years or days, just months. The segfault can be avoided by using lexical_cast<string, int> instead of lexical_cast<string>, but this shouldn't be necessary.
Test case (note that WinXP doesn't complain when programs segfault, hence the Begin/End business): crash.cc: ---- #include <boost/lexical_cast.hpp> #include <boost/date_time/posix_time/posix_time.hpp> #include <iostream> using namespace std; using namespace boost; using namespace boost::posix_time; using namespace boost::gregorian; int main() { const ptime t(date(1969, Jul, 21), time_duration(2, 56, 15)); cout << "Begin!" << endl; cout << lexical_cast<string>(t.date().month()) << endl; cout << "End!" << endl; } ---- WinXP, MinGW, gcc 3.3, Boost 1.30.0: ---- C:\Temp>gpp -Wall -W crash.cc -o crash.exe C:\Temp>crash Begin! C:\Temp> ---- Red Hat 9, gcc 3.3, Boost 1.30.0: ---- [08/05/2003 Tue 05:26.26 PM [EMAIL PROTECTED] ~] > gpp -Wall -W crash.cc -o crash [08/05/2003 Tue 05:26.39 PM [EMAIL PROTECTED] ~] > crash Begin! Segmentation fault [08/05/2003 Tue 05:26.40 PM [EMAIL PROTECTED] ~] > ---- fine.cc: ---- #include <boost/lexical_cast.hpp> #include <boost/date_time/posix_time/posix_time.hpp> #include <iostream> using namespace std; using namespace boost; using namespace boost::posix_time; using namespace boost::gregorian; int main() { const ptime t(date(1969, Jul, 21), time_duration(2, 56, 15)); cout << "Begin!" << endl; cout << lexical_cast<string, int>(t.date().month()) << endl; cout << "End!" << endl; } ---- WinXP: ---- C:\Temp>gpp -Wall -W fine.cc -o fine.exe C:\Temp>fine Begin! 7 End! C:\Temp> ---- Red Hat: ---- [08/05/2003 Tue 05:29.03 PM [EMAIL PROTECTED] ~] > gpp -Wall -W fine.cc -o fine [08/05/2003 Tue 05:29.13 PM [EMAIL PROTECTED] ~] > fine Begin! 7 End! [08/05/2003 Tue 05:29.14 PM [EMAIL PROTECTED] ~] > ---- Stephan T. Lavavej http://stl.caltech.edu _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost