String-to-float conversion functions in C have portability issues with error checking. The C standard ties error reporting to math_errhandling, but POSIX always requires errno to be set on overflow/underflow, creating potential non-conformance. Additionally, malformed input detection differs between standards: C uses the endptr parameter while POSIX optionally sets errno to EINVAL.
Standard C lacks a portable way to detect string-to-float conversion errors because math_errhandling doesn't consistently govern errno behavior in strtod and related functions. POSIX requires errno to be set on overflow/underflow, but C's specification is unclear, and malformed input detection relies on checking the endptr parameter rather than errno.
This post compares how glibc and musl handle C99's math_errhandling macro for reporting errors in math.h functions. Modern glibc supports both errno and floating-point exceptions, while musl always reports only exceptions; the author recommends portable code validate inputs and outputs directly rather than relying on error-reporting mechanisms.