Please keep bug-bison@gnu.org.

> Le 18 août 2018 à 15:53, 長田偉伸 <cbh34...@iret.co.jp> 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 <akim.demai...@gmail.com>
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            w...@mpi-sb.mpg.de
 Wwp                       subscr...@free.fr
 xolodho                   xolo...@gmail.com
 Zack Weinberg             z...@codesourcery.com
+長田偉伸                   cbh34...@iret.co.jp
 
 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));
     }
   };
 


Reply via email to