boost::optional bug in 1.33.1

Hello, the following code fails using Boost 1.33.1, gcc version 3.4.2 (mingw-special): boost::optional<double> x; x=boost::optional<float>(boost::none); // converting assignment with the following error message: Assertion failed: this->is_initialized(), file ...boost/optional/optional.hpp, line 531 Replacing template<class U> optional& operator= ( optional<U> const& rhs ) { this->assign(rhs.get()); return *this ; } by e.g. template<class U> optional& operator= ( optional<U> const& rhs ) { if(rhs) this->assign(rhs.get()); else this->reset(); return *this ; } should fix the bug. Regards, Michael

Hi Michael,
Hello,
the following code fails using Boost 1.33.1, gcc version 3.4.2 (mingw-special):
boost::optional<double> x; x=boost::optional<float>(boost::none); // converting assignment
with the following error message:
Assertion failed: this->is_initialized(), file ...boost/optional/optional.hpp, line 531
Thank you for the report and the fix. I'll integrate it next week. Best regards -- ------ Fernando Cacciola SciSoft http://certuscode.wordpress.com http://fcacciola.50webs.com http://fcacciola.wordpress.com
participants (2)
-
Fernando Cacciola
-
Michael Walter