Boost logo

Boost Users :

Subject: [Boost-users] boost::thread - many compiler warnings
From: Manfred Schwind (lists_at_[hidden])
Date: 2010-04-21 04:35:28


Hi,

we are using boost to develp cross-platform stuff. I am the Mac developer. The Mac is a 64 bit Intel machine, development environment is Xcode, of course, using gcc as compiler.

To create code as robust as possible I always turn on as many warning levels as possible. Usually I am using this:
-Wall -Wextra -Wconversion -Wshorten-64-to-32

This worked great with all basic boost stuff that we've used previously.
Now I tried just to include thread.hpp and I get many many compiler warnings!
I just do:

#include "boost/thread.hpp"

The warnings are just two kinds of warnings:
1.) warning: implicit conversion shortens 64-bit value into a 32-bit value
2.) warning: missing initializer for member '...'

An example for the first warning can be found in gregorian_calender.ipp (just showing relevant parts):

template<typename ymd_type_, typename date_int_type_>
BOOST_DATE_TIME_INLINE
int
gregorian_calendar_base<ymd_type_,date_int_type_>::week_number(const ymd_type& ymd) {
        ...
        unsigned long week = (juliantoday + day - julianbegin + 4)/7;
        if ((week >= 1) && (week <= 52)) {
                return week;
        }
        ...

Here's clearly missing a cast to tell the compiler that it's ok to return the unisigned long as int.
On most 64 bit systems, long is 64 bit but int is 32 bit.

The second warning is caused by the following line in conversion.hpp:

std::tm datetm = {}; // zero initialization is needed for extension members, like tm_zone

In this line I get the "missing initializer" warning for every member of the struct, e.g. tm::tm_sec, tm::tm_min, tm::tm_hour etc.
What's the intension by initializing with empty braces? IMO this is not a standard initialization method.

Is there any chance that these errors get fixed? Any ideas how to use thread.hpp without reducing my warning levels? Does anyone have the same problems?

Regards,
Manfred Schwind

--
http://mani.de - friendly software
iVolume - listen to music hands-free
LittleSecrets - the encrypted notepad
Sahara - sand in your pocket
Watchdog - baffle the curious

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net