Ordered comparison of iconv_t (which is, behind the scenes, a void *) with zero fails with recent clang, such as in Xcode 9 on macOS 10.13 (the system's default compiler).
Upon successful completion, iconv_open() returns a conversion descriptor for use on subsequent calls to iconv(). Otherwise iconv_open() returns (iconv_t)-1 and sets errno to indicate the error.
Thus the check for error is not cd < 0 but cd == (iconv_t)-1.
Ordered comparison of
iconv_t
(which is, behind the scenes, avoid *
) with zero fails with recent clang, such as in Xcode 9 on macOS 10.13 (the system's default compiler).The standards clearly state that:
Thus the check for error is not
cd < 0
butcd == (iconv_t)-1
.