
Hi, When I use boost::optional I often see gcc warnings about using possibly uninitialized values. I've seen such warnings in my projects outside Boost but now I encountered them in Boost.Log. Building the current develop with gcc 4.8 I see this: ./boost/date_time/constrained_value.hpp: In member function ‘boost::shared_ptr<boost::log::v2_mt_posix::sinks::sink> boost::log::v2_mt_posix:: {anonymous}::default_text_file_sink_factory<CharT>::create_sink(const settings_section&) [with CharT = wchar_t; boost::log::v2_mt_posix:: {anonymous}::default_text_file_sink_factory<CharT>::settings_section = boost::log::v2_mt_posix::basic_settings_section<wchar_t>]’: ./boost/date_time/constrained_value.hpp:76:7: warning: ‘*((void*)& day +2)’ may be used uninitialized in this function [-Wmaybe-uninitialized] value_ = value; ^ libs/log/src/init_from_settings.cpp:172:32: note: ‘*((void*)& day +2)’ was declared here optional< unsigned short > day; ^ libs/log/src/init_from_settings.cpp:249:87: warning: ‘*((void*)& weekday +4)’ may be used uninitialized in this function [-Wmaybe-uninitialized] return sinks::file::rotation_at_time_point(weekday.get(), hour, minute, second); ^ libs/log/src/init_from_settings.cpp:171:37: note: ‘*((void*)& weekday +4)’ was declared here optional< date_time::weekdays > weekday; ^ I attached the full log for convenience. The code in question is this function: https://github.com/boostorg/log/blob/develop/src/init_from_settings.cpp#L171 Note that at line 248 and below I check that the optional is filled before using it, so there is no way I'll be accessing any uninitialized data (that is, if boost::optional behaves correctly). I suspect this may be a compiler bug. I tried to create a minimal example to reproduce it but the warning doesn't show in a simple context. However, I'd like it to be worked around somehow (unless it's an actual bug in boost::optional). Any suggestions? Am I missing a bug in my code?