[Top][All Lists]

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

Re: [PATCH 0/3] yacc: compute the best type for the state number

From: Hans Åberg
Subject: Re: [PATCH 0/3] yacc: compute the best type for the state number
Date: Wed, 2 Oct 2019 10:53:24 +0200

> On 2 Oct 2019, at 00:43, Paul Eggert <address@hidden> wrote:
> However, we should avoid unsigned types that are 'unsigned' or wider, as they 
> have too many issues. I doubt whether there are practical uses of Bison with 
> more than INT_MAX states; but if there are, we should use ptrdiff_t to count 
> states, not int, because any application likely to exceed INT_MAX is also 
> pretty likely to exceed UINT_MAX.
> There is an area where Bison uses 'int' when it should use a wider type, 
> presumably intmax_t. This is for line and column numbers, which these come 
> from input files and can exceed INT_MAX in some practical cases. Fixing that 
> could be a subject of a different patch.
> There are no doubt other uses of 'int' in Bison for indexes should be changed 
> to ptrdiff_t, for things like stack depth where Bison should not impose 
> arbitrary limits. I think I should take a look at that next; this will 
> probably entail improvements to the patch I proposed.

For C++, I use
  typedef std::ptrdiff_t int_type;
  typedef std::size_t size_type;

In C++ one uses fpos_t for file positions [1], in functions like std::fgetpos 

1. https://en.cppreference.com/w/cpp/io/c
2. https://en.cppreference.com/w/cpp/io/c/fgetpos

reply via email to

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