Checking errno alone misses invalid C floating-point input
A C parsing investigation shows why checking errno alone after strtod can miss invalid input. For the string “x”, the author reports no errno change with glibc but EINVAL with musl. The end pointer identifies whether any characters were converted. The article also separates POSIX range-error requirements from standard C, where underflow reporting is implementation-defined; portability depends on which contract you target.
sebsite · Oct 9, 2026
Why it matters
Input validation can silently differ between libc implementations even when both builds compile cleanly.
More context
Review conversion code for an end-pointer check and test malformed inputs on supported platforms. Distinguish no conversion from trailing characters and range errors. The article discusses disputed standard wording; its interpretations are not a standards-body ruling.
Keep in mind
The examples focus on floating-point conversion and do not establish a universal error-checking recipe for all C library calls.
Original read