Boost logo

Boost :

From: David Abrahams (abrahams_at_[hidden])
Date: 2000-07-13 22:16:53


From: "Mark Rodgers" <mark.rodgers_at_[hidden]>

> > These tricks work for GCC
> > 2.95.2, but I've been unable to get them to work with MSVC6.
> ...
> > I think there might be trouble with Borland, though.
>
> Is it MSVC or STLport? I removed all the #ifdefs so that it
> was using your new method always and I found:

Well, it was MSVC/STLport and GCC 2.95.2/STLport

> 1. It worked fine with both Borland compilers I use, and did
> indeed eliminate the warnings, although so does a simple
> #pragma warn -8012

Oh, that's nice! I knew Borland was having some trouble with (partial)
specialization on non-type (bool) template paramters in operators.hpp, so I
suspected it wouldn't work.

> 2. MSVC didn't generate any warnings until I bumped the warning
> level up to 4, and then your change worked fine and did
> reduce the cast_test.cpp warnings from 55 down to 47.

Terriffic. I think the difference is that MSVC's native <limits> uses enums
to define static constants, and the compiler is able to use these at compile
time. The STLport uses out-of-line static const bools.
Boris, take note!

> 3. It wouldn't work with GCC 2.95.2 at all due to a lack of
> <limits>

Try w/STLport. GCC is one of the worst cases, since there's no way to turn
on and off warnings dynamically.

> 4. When I added the following test
>
<snip>
>
> It failed (didn't throw). That's because I don't think the
> last test is correct:
>
> template <>
> struct greater_than_type_max<false>
> {
> template <class X, class Y>
> static bool check(X x, Y)
> { return x >= 0 && static_cast<X>(static_cast<Y>(x)) == x; }
> };
>
> This seems to be checking that it didn't overflow rather than
> that it would. So the following test also failed

Oh, thanks! I'll reverse the test.

> I always think it is worthwhile to eliminate warnings by doing
> the right thing rather than simply suppressing them with a
> #pragma, so keep it up.

Thanks for the feedback,
Dave


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk