[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [lmi] More enabled warnings, less boost
From: |
Greg Chicares |
Subject: |
Re: [lmi] More enabled warnings, less boost |
Date: |
Mon, 6 Feb 2017 20:02:40 +0000 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Icedove/45.6.0 |
On 2017-02-06 17:58, Vadim Zeitlin wrote:
> On Mon, 6 Feb 2017 15:35:42 +0000 Greg Chicares <address@hidden> wrote:
>
[...pragma GCC push, pop, etc. ...]
>
> GC> No, thanks. I already tried those pragmata. I wrote them around
> GC> calls to boost facilities. I wrote them around inclusions of
> GC> boost headers. I still got the same number of lines of compiler
> GC> diagnostics (8932 lines or so). Searching the web, all signs
> GC> point to an open defect on gcc's bugzilla.
>
> I couldn't find any bugs related to this, could you please give a link to
> this one?
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53431
> GC> So I took a different approach. Here's one thing that helped:
> GC>
> GC> -DBOOST_STATIC_ASSERT_HPP \
> GC> -D'BOOST_STATIC_ASSERT(A)=static_assert((A),"")' \
> GC>
> GC> If that tickles your fancy, I'm willing to share the whole set
> GC> of changes with you,
>
> The simplest would be to commit them to some experimental/Wconversion
> branch in the git repository, then I could not only look at it, but it
> would also make working on it and completing these changes easier in the
> future.
They're far too embarrassing to publish. "Pauca sed matura", as Gauss said.
> GC> int cents() const
> GC> {
> GC> // return cents_ % cents_per_dollar;
> GC> // C++11 [5.6/4]: "if the quotient a/b is representable in the
> GC> // type of the result, (a/b)*b + a%b is equal to a"
> GC> return static_cast<int>(cents_ - (cents_ / cents_per_dollar) *
> cents_per_dollar);
> GC> }
>
> I don't understand how is this preferable to
>
> return static_cast<int>(cents_ % cents_per_dollar);
>
> ?
IIRC, with '-Wconversion', gcc flagged "cents_ % cents_per_dollar"
as suspicious in itself because the operands are of different types.
> GC> Maybe I should have used modf() or fmod(), but that would
> GC> have required too much thought for this quick exercise.
>
> I don't see how would it have helped neither, to be honest?
Superstition perhaps. I'm aware that some very smart people added
functions like those to C for a reason, and the reason, AIUI, is
somehow related to what gcc seemed to be objecting to here. I know
the motivation is to prevent splitting $1.99 into dollars and cents
and getting an answer like two dollars and negative one cents, but
I always seem to get this wrong if I try to go too fast.
- [lmi] Default values for default arguments, Greg Chicares, 2017/02/03
- Re: [lmi] Default values for default arguments, Vadim Zeitlin, 2017/02/04
- Re: [lmi] Default values for default arguments, Greg Chicares, 2017/02/04
- Re: [lmi] Default values for default arguments, Vadim Zeitlin, 2017/02/04
- [lmi] Third-millennium GOTW#1: is <int> special? [Was: Default values for default arguments], Greg Chicares, 2017/02/04
- Re: [lmi] Third-millennium GOTW#1: is <int> special?, Vadim Zeitlin, 2017/02/04
- Re: [lmi] Third-millennium GOTW#1: is <int> special?, Greg Chicares, 2017/02/05
- Re: [lmi] Third-millennium GOTW#1: is <int> special?, Vadim Zeitlin, 2017/02/06
- [lmi] More enabled warnings, less boost [Was: Third-millennium GOTW#1: is <int> special?], Greg Chicares, 2017/02/06
- Re: [lmi] More enabled warnings, less boost, Vadim Zeitlin, 2017/02/06
- Re: [lmi] More enabled warnings, less boost,
Greg Chicares <=
- Re: [lmi] More enabled warnings, less boost, Vadim Zeitlin, 2017/02/06
Re: [lmi] Default values for default arguments, Greg Chicares, 2017/02/10
- Re: [lmi] Default values for default arguments, Vadim Zeitlin, 2017/02/10
- Re: [lmi] Default values for default arguments, Greg Chicares, 2017/02/11
- Re: [lmi] Default values for default arguments, Greg Chicares, 2017/02/11
- Re: [lmi] Default values for default arguments, Vadim Zeitlin, 2017/02/11
- Re: [lmi] Default values for default arguments, Greg Chicares, 2017/02/11
- Re: [lmi] Default values for default arguments, Vadim Zeitlin, 2017/02/11
[lmi] () or {} in initializer lists [Was: Default values for default arguments], Greg Chicares, 2017/02/22
Re: [lmi] () or {} in initializer lists [Was: Default values for default arguments], Vadim Zeitlin, 2017/02/22