[tz] Compiler warning in tzcode2016g about SIZE_MAX being wider than int
eggert at cs.ucla.edu
Thu Oct 20 23:05:55 UTC 2016
On 10/20/2016 10:15 AM, Tom Lane wrote:
> Or in other words, clang is pointing out, quite correctly, that SIZE_MAX
> won't fit in an int. This doesn't represent a runtime bug
Yes, it's a false alarm. I often get false alarms like that when using
Clang. I've been too lazy to report them to the Clang maintainers, but
perhaps you can find the energy....
> I am not aware of any C implementation that
> has ever had INT_MAX > SIZE_MAX, and surely there are none in use today.
The test is there partly because the code attempts to be as portable as
possible, and partly because the code shouldn't limit the number of
zones etc. to INT_MAX and this test is a placeholder for fixing that
problem later. Generally speaking in C, object sizes should be limited
only by min(PTRDIFF_MAX, SIZE_MAX).
I'll see if I can rewrite the code to remove the INT_MAX restriction,
which is arbitrary here. Not sure whether this will pacify Clang, but
it's really a Clang bug so this is low priority.
More information about the tz