在 2026-2-9 21:22, Richard Biener 写道:
On Mon, Feb 9, 2026 at 1:39 PM LIU Hao <[email protected]> wrote:The MSVCRT `strtoul()` function, which is called indirectly by `libiberty_vprintf_buffer_size()`, resets `errno` to zero upon success.Isn't the better fix to save/restore around the strtoul() call then? And best have a comment explaining why we do it.
Sure, that's acceptable too. I'll send a new patch.
I had the idea that errno is never altered on success, but now I see the strtoul manpage explicitly documents that. I'm confused.
POSIX says 'these functions shall not change the setting of errno if successful.' [1] But despite that, if an empty string is passed, it may still set errno to EINVAL.
[1] https://pubs.opengroup.org/onlinepubs/9799919799/functions/strtoul.html -- Best regards, LIU Hao
OpenPGP_signature.asc
Description: OpenPGP digital signature
