On 10/31/2020 11:27 PM, Laslo Hunhold wrote:

this is a great catch, thanks! But wouldn't it be better to use
MIN(SIZE_MAX, LLONG_MAX)?

I haven't found anything in the standard that puts "long long" and
"size_t" into any relation, which means, for me, that any case is
possible where either value could be larger, but please correct me if
I'm wrong.

Good point! It could be the case that SIZE_MAX is smaller than LLONG_MAX. Honestly I don't know, but I would do what you are proposing just to be sure: it is the safest option, and maybe the compiler will take care of replacing the correct value at compile time. Way better than leaving another bug lingering until someone else finds it again.

Best regards,
José Miguel


Reply via email to