Proposed Patch for Bug 69687

Joseph Myers joseph@codesourcery.com
Fri Mar 4 23:57:00 GMT 2016


On Thu, 3 Mar 2016, Mike Stump wrote:

> On Mar 3, 2016, at 6:21 AM, Bernd Schmidt <bschmidt@redhat.com> wrote:
> > What C standard can we assume for libiberty? I was looking at patching this and discovered that SIZE_MAX is defined only for C99, so I'm leaning towards retaining the ints and using INT_MAX.
> 
> As long as you donÂ’t need a constantÂ…  you can also do something like:
> 
> #ifndef SIZE_MAX
> #define SIZE_MAX   (sizeof (size_t) == sizeof (int) ? INT_MAX : sizeof (size_t) == sizeof (long) ? LONG_MAX : (abort (), 0))
> #endif

If you don't require usability in #if (so can use casts), ((size_t) -1) 
suffices as a value of SIZE_MAX (size_t is always unsigned).

-- 
Joseph S. Myers
joseph@codesourcery.com


More information about the Gcc-patches mailing list