lmi
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lmi] More enabled warnings, less boost [Was: Third-millennium GOTW#1: i


From: Greg Chicares
Subject: [lmi] More enabled warnings, less boost [Was: Third-millennium GOTW#1: is <int> special?]
Date: Mon, 6 Feb 2017 15:35:42 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Icedove/45.6.0

On 2017-02-06 15:05, Vadim Zeitlin wrote:
> On Sun, 5 Feb 2017 12:31:19 +0000 Greg Chicares <address@hidden> wrote:
> 
> GC> On 2017-02-04 22:16, Vadim Zeitlin wrote:
> GC> > On Sat, 4 Feb 2017 19:12:23 +0000 Greg Chicares <address@hidden> wrote:
> GC> [...]
> GC> > GC> +    std::vector<double> d2(5.0, 7.0);    // size 5
> GC> > GC> +    std::vector<double> d3(5.1L, 7.0);   // size 5
> GC> > 
> GC> >  And those should warn about implicit double-to-int conversion, so 
> they're
> GC> > not that bad.
> GC> 
> GC> But they don't, because we have '-Wno-conversion' due to boost.
> 
>  It's indeed a pity to have to disable this warning globally. Now that we
> use Boost in fewer places than before and we require a sufficiently new
> compiler, could we perhaps use GCC diagnostic push/ignored/pop pragmas to
> disable the warning just in the Boost headers it appears in instead of
> doing it everywhere?
> 
>  Please let me know if you'd like me to [try to] do this,

No, thanks. I already tried those pragmata. I wrote them around
calls to boost facilities. I wrote them around inclusions of
boost headers. I still got the same number of lines of compiler
diagnostics (8932 lines or so). Searching the web, all signs
point to an open defect on gcc's bugzilla.

So I took a different approach. Here's one thing that helped:

  -DBOOST_STATIC_ASSERT_HPP \
  -D'BOOST_STATIC_ASSERT(A)=static_assert((A),"")' \

If that tickles your fancy, I'm willing to share the whole set
of changes with you, but the rest are pretty casual. One vital
step is replacing boost's numeric_cast; for this speedy proof
of concept, though, I replaced it with static_cast. Another
example, in SET_LDOUBLE_WORDS:
-  iw_u.parts.sign_exponent = (exp);                             \
+  iw_u.parts.sign_exponent = (short int)(exp);                             \
With a host of other "expedient" changes in lmi source only
(none in boost--it's madness to touch that), I got everything
working with
    -Wno-conversion \
    -Wno-unused-local-typedefs \
    -Wno-unused-variable \
I still used
    -Wno-deprecated-declarations \
because I haven't upgraded xmlwrapp, and
    -Wno-parentheses \
because those warnings are nonsense (think of AND and OR as
multiplicative and additive operations respectively, and it
all becomes about as confusing as "1 + 2 * 3").

If you still want to see the changes, there are some items on
which you might like to opine, e.g.:

    int cents() const
        {
//      return cents_ % cents_per_dollar;
        // C++11 [5.6/4]: "if the quotient a/b is representable in the
        // type of the result, (a/b)*b + a%b is equal to a"
        return static_cast<int>(cents_ - (cents_ / cents_per_dollar) * 
cents_per_dollar);
        }

Maybe I should have used modf() or fmod(), but that would
have required too much thought for this quick exercise.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]