Re: [PATCH] scanf.3: Do not mention the ERANGE error

Ian Abbott
2022-12-14T11:03:55Z

On 2022-12-14 10:47, Alejandro Colomar wrote:
> On 12/14/22 03:13, Zack Weinberg wrote:
>> Alejandro Colomar <alx.manpages@gmail.com> writes:
>>>> In a more sober tone of voice I suggest this text for the manpage:
>> …
>>> That makes sense to me.  Would you mind sending a patch?  :)
>>
>> I do not have time to do that anytime soon.  Also, maybe glibc’s
>> behavior on numeric input overflow should be fixed first.
>
> That also makes sense ;)
>
> In short:
>
> (1)  Numeric conversion specifiers are broken but can be fixed, and you
> plan to fix them.
>
>      (1.1)  I'll revert the deprecation warning now; since they are
> only broken because the _current_ standard and implementations are
> broken, but not by inherent design problems.
>
>      (1.2)  When you fix the implementation to not be UB anymore, it
> will also make sense to revert the patch that removed the ERANGE error,
> since you'll need to report it.

And would ERANGE cause scanf to return EOF in the fixed implementation?
That seems like it would break a lot of existing code (even though it is
currently UB). It would probably be better to silently set errno to
ERANGE without returning EOF, and to set the integer object's value to
the maximum or minimum value for its type (as it currently does for
signed/unsigned long).

--
-=( Ian Abbott <abbotti@mev.co.uk> || MEV Ltd. is a company )=-
-=( registered in England & Wales. Regd. number: 02862268. )=-
-=( Regd. addr.: S11 & 12 Building 67, Europa Business Park, )=-
-=( Bird Hall Lane, STOCKPORT, SK3 0XA, UK. || www.mev.co.uk )=-