|
Boost : |
Subject: [boost] boost::date_time and gcc-4.3 with enabled optimization.
From: Dmitry V. Krivenok (krivenok_at_[hidden])
Date: 2008-12-30 04:08:53
Hello!
Please look at this simple example:
krivenok_at_develop2 11:51:44 /tmp/date $ cat date.cpp
#include <string>
#include <boost/date_time.hpp>
const std::string Date(boost::posix_time::ptime posix_time)
{
return boost::gregorian::to_iso_extended_string(posix_time.date());
}
krivenok_at_develop2 11:51:54 /tmp/date $
I have two compilers (gcc-4.1.2 and gcc-4.3.2) and boost-1.37.0
installed on my linux host.
I wrote simple test to demonstrate the problem:
krivenok_at_develop2 11:51:54 /tmp/date $ export CC=g++-4.1.2
krivenok_at_develop2 11:52:32 /tmp/date $ for((i=0;i<4;i++)) do echo
"Optimization level $i" ; $CC -O$i -Wall -I/usr/local/dev/boost/include/
date.cpp -c ; done
Optimization level 0
Optimization level 1
Optimization level 2
Optimization level 3
krivenok_at_develop2 11:52:40 /tmp/date $ export CC=g++-4.3.2
krivenok_at_develop2 11:52:44 /tmp/date $ for((i=0;i<4;i++)) do echo
"Optimization level $i" ; $CC -O$i -Wall -I/usr/local/dev/boost/include/
date.cpp -c ; done
Optimization level 0
Optimization level 1
/usr/local/dev/boost/include/boost/date_time/constrained_value.hpp: In
function 'const std::string Date(boost::posix_time::ptime)':
/usr/local/dev/boost/include/boost/date_time/constrained_value.hpp:68:
warning:
'year.boost::gregorian::greg_year::<anonymous>.boost::CV::constrained_value<boost::CV::simple_exception_policy<short
unsigned int, 1400u, 10000u, boost::gregorian::bad_year> >::value_' may
be used uninitialized in this function
/usr/local/dev/boost/include/boost/date_time/gregorian_calendar.ipp:122:
note:
'year.boost::gregorian::greg_year::<anonymous>.boost::CV::constrained_value<boost::CV::simple_exception_policy<short
unsigned int, 1400u, 10000u, boost::gregorian::bad_year> >::value_' was
declared here
/usr/local/dev/boost/include/boost/date_time/constrained_value.hpp:64:
warning:
'year.boost::gregorian::greg_year::<anonymous>.boost::CV::constrained_value<boost::CV::simple_exception_policy<short
unsigned int, 1400u, 10000u, boost::gregorian::bad_year> >::value_' may
be used uninitialized in this function
/usr/local/dev/boost/include/boost/date_time/gregorian_calendar.ipp:122:
note:
'year.boost::gregorian::greg_year::<anonymous>.boost::CV::constrained_value<boost::CV::simple_exception_policy<short
unsigned int, 1400u, 10000u, boost::gregorian::bad_year> >::value_' was
declared here
Optimization level 2
/usr/local/dev/boost/include/boost/date_time/constrained_value.hpp: In
function 'const std::string Date(boost::posix_time::ptime)':
/usr/local/dev/boost/include/boost/date_time/constrained_value.hpp:68:
warning:
'year.boost::gregorian::greg_year::<anonymous>.boost::CV::constrained_value<boost::CV::simple_exception_policy<short
unsigned int, 1400u, 10000u, boost::gregorian::bad_year> >::value_' may
be used uninitialized in this function
/usr/local/dev/boost/include/boost/date_time/gregorian_calendar.ipp:122:
note:
'year.boost::gregorian::greg_year::<anonymous>.boost::CV::constrained_value<boost::CV::simple_exception_policy<short
unsigned int, 1400u, 10000u, boost::gregorian::bad_year> >::value_' was
declared here
/usr/local/dev/boost/include/boost/date_time/constrained_value.hpp:64:
warning:
'year.boost::gregorian::greg_year::<anonymous>.boost::CV::constrained_value<boost::CV::simple_exception_policy<short
unsigned int, 1400u, 10000u, boost::gregorian::bad_year> >::value_' may
be used uninitialized in this function
/usr/local/dev/boost/include/boost/date_time/gregorian_calendar.ipp:122:
note:
'year.boost::gregorian::greg_year::<anonymous>.boost::CV::constrained_value<boost::CV::simple_exception_policy<short
unsigned int, 1400u, 10000u, boost::gregorian::bad_year> >::value_' was
declared here
Optimization level 3
/usr/local/dev/boost/include/boost/date_time/constrained_value.hpp: In
function 'const std::string Date(boost::posix_time::ptime)':
/usr/local/dev/boost/include/boost/date_time/constrained_value.hpp:68:
warning:
'year.boost::gregorian::greg_year::<anonymous>.boost::CV::constrained_value<boost::CV::simple_exception_policy<short
unsigned int, 1400u, 10000u, boost::gregorian::bad_year> >::value_' may
be used uninitialized in this function
/usr/local/dev/boost/include/boost/date_time/gregorian_calendar.ipp:122:
note:
'year.boost::gregorian::greg_year::<anonymous>.boost::CV::constrained_value<boost::CV::simple_exception_policy<short
unsigned int, 1400u, 10000u, boost::gregorian::bad_year> >::value_' was
declared here
/usr/local/dev/boost/include/boost/date_time/constrained_value.hpp:64:
warning:
'year.boost::gregorian::greg_year::<anonymous>.boost::CV::constrained_value<boost::CV::simple_exception_policy<short
unsigned int, 1400u, 10000u, boost::gregorian::bad_year> >::value_' may
be used uninitialized in this function
/usr/local/dev/boost/include/boost/date_time/gregorian_calendar.ipp:122:
note:
'year.boost::gregorian::greg_year::<anonymous>.boost::CV::constrained_value<boost::CV::simple_exception_policy<short
unsigned int, 1400u, 10000u, boost::gregorian::bad_year> >::value_' was
declared here
krivenok_at_develop2 11:52:50 /tmp/date $
As you can see the example compiled using gcc-4.1.2 compiles without any
warnings
regardless of optimization level.
However, gcc-4.3.2 produces a lot of strange warnings if optimization is
enabled.
I don't really know is it gcc or boost issue.
Is it safe to use boost::date_time with gcc-4.3.2 and -O3 optimization
level?
Thank you beforehand!
-- Sincerely yours, Dmitry V. Krivenok Orange System Company Saint-Petersburg, Russia work phone: +7 812 332-32-40 cellular phone: +7 921 576-70-91 e-mail: krivenok_at_[hidden] web: http://www.orangesystem.ru skype: krivenok_dmitry jabber: krivenok_dmitry_at_[hidden] icq: 242-526-443
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk