Boost logo

Boost Users :

From: John Maddock (john_at_[hidden])
Date: 2005-07-09 11:04:22

> I think this is caused by trying to call the convertible_from<char>
> constructor (which takes a char) with a float& argument, which forces an
> implicit conversion from float-to-char BEFORE the "user defined
> conversion" of char-to-convertible_from<char>.

Right: we are quite deliberately testing conversions that go via both a
builtin conversion and a user defined constructor.

> gcc issues this warning when doing a float(or double) conversion to an
> integral type during template instantiation/overload resolution -- but
> does not warn if "merely" truncating from a wider integral
> representation down to char. I can see why gcc might warn in each case
> -- but
> (1) warning in one case but not the other seems counterintuitive
> (2) in any case, I'd like to suppress or avoid both sorts of warnings
> Does anybody have an idea how to avoid these warnings with gcc -- or can
> verify that they occur with other versions of gcc (like 4.0?).
> It's also possible that I'm confused :-) and gcc's behavior is correct;
> but that means that boost::is_convertible is deliberately violating some
> rule or other and causing these warnings -- and I doubt that is the case.

Compilers are permitted to warn over anything they want (and often do so!),
so gcc is completely within it's rights to issue a warning here.

For other compilers we've gone to some lengths to disable warnings like this
within is_convertible using #pragmas, unfortunately gcc doesn't have any
options that help here. We also use some "special case code" to ensure that
conversions from a [cv-qualified reference to] arithmetic or enum type to
another arithmetic type doesn't result in warnings on gcc. Unfortunately we
can't extend that to user defined types :-(

Sorry this isn't more helpful,


Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at