|
Boost Users : |
Subject: [Boost-users] Conversion warning from boost/functional/hash/detail/hash_float_generic.hpp
From: Greg Ward (greg_at_[hidden])
Date: 2010-11-19 13:16:16
Hi all --
I'm getting a strange warning from
<boost/functional/hash/detail/hash_float_generic.hpp>. What's strange
is not the warning, but the circumstances: if I use the boost headers
installed in /usr/include, no warning. But if I make a copy of
/usr/include/boost and tell the compiler to use the copy, I get a
warning. I can reproduce this on CentOS 5 using our custom build of
GCC 4.4.4 and boost 1.44.0, and on Ubuntu 10.04 (lucid) using Ubuntu's
builds of GCC 4.4.3 and boost 1.40.0.
It doesn't take much code to reproduce the problem:
$ cat test.cpp
#include <boost/functional/hash.hpp>
First, a good build using Ubuntu /usr/bin/g++ (4.4.3) and
/usr/include/boost (1.40.0)
$ /usr/bin/g++ -Wall -Wconversion -c test.cpp -o test.o
[no warnings]
Now let's make a copy of the boost headers and use the copy:
$ mkdir include
$ cp -rp /usr/include/boost include/.
$ /usr/bin/g++ -Wall -Wconversion -I include -c test.cpp -o test.o
In file included from include/boost/functional/hash/detail/hash_float.hpp:30,
from include/boost/functional/hash/hash.hpp:15,
from include/boost/functional/hash.hpp:6,
from test.cpp:1:
include/boost/functional/hash/detail/hash_float_generic.hpp: In
function âsize_t boost::hash_detail::float_hash_impl2(T) [with T =
float]â:
include/boost/functional/hash/detail/hash_float_generic.hpp:84:
instantiated from âsize_t boost::hash_detail::float_hash_impl(T) [with
T = float]â
include/boost/functional/hash/detail/hash_float.hpp:74: instantiated
from âsize_t boost::hash_detail::float_hash_value(T) [with T = float]â
include/boost/functional/hash/hash.hpp:282: instantiated from here
include/boost/functional/hash/detail/hash_float_generic.hpp:59:
warning: conversion to âfloatâ from âsize_tâ may alter its value
include/boost/functional/hash/detail/hash_float_generic.hpp:84:
instantiated from âsize_t boost::hash_detail::float_hash_impl(T) [with
T = float]â
include/boost/functional/hash/detail/hash_float.hpp:74: instantiated
from âsize_t boost::hash_detail::float_hash_value(T) [with T = float]â
include/boost/functional/hash/hash.hpp:282: instantiated from here
include/boost/functional/hash/detail/hash_float_generic.hpp:71:
warning: conversion to âfloatâ from âsize_tâ may alter its value
I get the same behaviour if include/boost is a symlink to
/usr/include/boost. Changing "-I include" to an absolute path ("-I
`pwd`/include") makes no difference.
If I repeat the experiment on my CentOS 5 machine with custom builds
of more recent versions of GCC (4.4.4) and boost (1.44.0), I see the
same thing. The line numbers are slightly different:
In file included from include/boost/functional/hash/detail/hash_float.hpp:30,
from include/boost/functional/hash/hash.hpp:15,
from include/boost/functional/hash.hpp:6,
from test.cpp:1:
include/boost/functional/hash/detail/hash_float_generic.hpp: In
function âsize_t boost::hash_detail::float_hash_impl2(T) [with T =
float]â:
include/boost/functional/hash/detail/hash_float_generic.hpp:82:
instantiated from âsize_t boost::hash_detail::float_hash_impl(T) [with
T = float]â
include/boost/functional/hash/detail/hash_float.hpp:74: instantiated
from âsize_t boost::hash_detail::float_hash_value(T) [with T = float]â
include/boost/functional/hash/hash.hpp:315: instantiated from here
include/boost/functional/hash/detail/hash_float_generic.hpp:56:
warning: conversion to âfloatâ from âsize_tâ may alter its value
include/boost/functional/hash/detail/hash_float_generic.hpp:82:
instantiated from âsize_t boost::hash_detail::float_hash_impl(T) [with
T = float]â
include/boost/functional/hash/detail/hash_float.hpp:74: instantiated
from âsize_t boost::hash_detail::float_hash_value(T) [with T = float]â
include/boost/functional/hash/hash.hpp:315: instantiated from here
include/boost/functional/hash/detail/hash_float_generic.hpp:69:
warning: conversion to âfloatâ from âsize_tâ may alter its value
but obviously the trace through the header files is basically the same.
Any clues? Google did not turn up any similar problems from anyone else.
Oh yeah: if you're wondering why I want to use a copy of (or symlink
to) the real boost installation, it's because we need to support
building many different versions of our software, and they don't all
use the same versions of boost or gcc (or various other 3rd-party
components). So each build tree has a bunch of local symlinks
pointing to exactly the right versions of gcc, boost, etc.
Thanks!
Greg
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