[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: position.hh compile error C4146 (VisualStudio 2017)
From: |
長田偉伸 |
Subject: |
Re: position.hh compile error C4146 (VisualStudio 2017) |
Date: |
Sun, 19 Aug 2018 00:04:37 +0900 |
I tried it and confirmed that it works normally.
Thanks,
2018-08-18 23:45 GMT+09:00 Akim Demaille <address@hidden>:
> Please keep address@hidden
>
>> Le 18 août 2018 à 15:53, 長田偉伸 <address@hidden> a écrit :
>>
>> it is still broken.
>>
>>> Can I install this fix?
>>
>>> Would you also consider reporting this bug to MS?
>>
>> Sorry, I can not do anything.
>>
>> Because I can understand English only a little.
>> (I am Japanese)
>
> That’s fine :)
>
> The code was actually stupid. Please try this. Thanks!
>
> commit d32b0c7ee5d39bd33589fc5e62985a68ab78087e
> Author: Akim Demaille <address@hidden>
> Date: Sat Aug 18 16:37:47 2018 +0200
>
> C++: fix portability issue with MSVC 2017
>
> Visual Studio dies with parse error on '-static_cast<unsigned>(rhs)'.
> But the code
>
> return (0 < rhs || -static_cast<unsigned>(rhs) < lhs
> ? rhs + lhs
> : min);
>
> was really all wrong, it should have been
>
> return (0 < rhs || static_cast<unsigned>(-rhs) < lhs
> ? rhs + lhs
> : min);
>
> yet let's go back to using std::max (whose header is still included in
> position.hh...) like originally, but with all the needed casts.
>
> Reported by 長田偉伸.
>
> See also
> http://lists.gnu.org/archive/html/bug-bison/2013-02/msg00000.html
> and commit 75ae8299840bbd854fa2474d38402bbb933c6511.
>
> * data/location.cc (position::add_): Use std::max.
>
> diff --git a/THANKS b/THANKS
> index 33f23ed7..c655e3c6 100644
> --- a/THANKS
> +++ b/THANKS
> @@ -173,6 +173,7 @@ Wolfram Wagner address@hidden
> Wwp address@hidden
> xolodho address@hidden
> Zack Weinberg address@hidden
> +長田偉伸 address@hidden
>
> Many people are not named here because we lost track of them. We
> thank them! Please, help us keeping this list up to date.
> diff --git a/data/location.cc b/data/location.cc
> index 3cc949df..622ffd61 100644
> --- a/data/location.cc
> +++ b/data/location.cc
> @@ -73,12 +73,11 @@ m4_define([b4_position_define],
> unsigned column;
>
> private:
> - /// Compute max(min, lhs+rhs) (provided min <= lhs).
> + /// Compute max(min, lhs+rhs).
> static unsigned add_ (unsigned lhs, int rhs, unsigned min)
> {
> - return (0 < rhs || -static_cast<unsigned>(rhs) < lhs
> - ? rhs + lhs
> - : min);
> + return static_cast<unsigned>(std::max(static_cast<int>(min),
> + static_cast<int>(lhs) + rhs));
> }
> };
>
>
- position.hh compile error C4146 (VisualStudio 2017), 長田偉伸, 2018/08/18
- Re: position.hh compile error C4146 (VisualStudio 2017), Akim Demaille, 2018/08/18
- Message not available
- Message not available
- Re: position.hh compile error C4146 (VisualStudio 2017), 長田偉伸, 2018/08/18
- Re: position.hh compile error C4146 (VisualStudio 2017), Rici Lake, 2018/08/18
- Re: position.hh compile error C4146 (VisualStudio 2017), Akim Demaille, 2018/08/18
- Re: position.hh compile error C4146 (VisualStudio 2017), Rici Lake, 2018/08/18
- Re: position.hh compile error C4146 (VisualStudio 2017), Hans Åberg, 2018/08/19