This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Proposed Patch for Bug 69687
- From: Mike Stump <mikestump at comcast dot net>
- To: Bernd Schmidt <bschmidt at redhat dot com>
- Cc: Marcel Böhme <boehme dot marcel at gmail dot com>, gcc-patches at gcc dot gnu dot org
- Date: Thu, 3 Mar 2016 07:11:52 -0800
- Subject: Re: Proposed Patch for Bug 69687
- Authentication-results: sourceware.org; auth=none
- References: <EA6F36C4-86FE-4018-8CB0-D0F314C1528D at gmail dot com> <EBBC24E4-04F9-4A8F-9A5D-801BFF9009EF at comcast dot net> <56D8486B dot 5080900 at redhat dot com>
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
but, you need to consider the signedness of it. A size bounded by int might be annoying if an int was 16 bits, but, we don’t care about such platforms hosting gcc, so, not a problem in reality. Once we get to 32-biit (or more), we’re good. No one better have a symbol >2 billion bytes. And if they do, they can submit that patch to fix it in about 1000 years. :-) I think an INT_MAX only version is fine.