bug-gnulib
[Top][All Lists]
Advanced

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

Re: [PATCH] lib/xstrtol.c: Fix xstrtol() on EINVAL (invalid base)


From: Paul Eggert
Subject: Re: [PATCH] lib/xstrtol.c: Fix xstrtol() on EINVAL (invalid base)
Date: Thu, 25 Jul 2024 12:33:11 -0700
User-agent: Mozilla Thunderbird

On 2024-07-25 09:39, Alejandro Colomar wrote:

So, we have arrived there, tmp is 1, and the suffix is "k", so it will
be multiplied by 1000.

That's the expected behavior.


I passed a base of -1.

Fine, so don't do that. When you use base -1, it doesn't matter whether the behavior differs on platform A vs B. Portable code can't use base -1 with strtol; we'll get unspecified or even undefined behavior. It's OK if xstrtol also has unspecified or even undefined behavior when the base is -1.

Again, none of this matters in actual software that uses xstrtol. Let's move on to a different topic.



reply via email to

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