Bug 196540 - iconv() function violates POSIX
Summary: iconv() function violates POSIX
Status: Closed DUPLICATE of bug 199099
Alias: None
Product: Base System
Classification: Unclassified
Component: standards (show other bugs)
Version: 10.1-RELEASE
Hardware: Any Any
: --- Affects Some People
Assignee: freebsd-standards (Nobody)
Depends on:
Reported: 2015-01-06 13:04 UTC by vi0xrhvpa
Modified: 2015-07-06 15:03 UTC (History)
2 users (show)

See Also:


Note You need to log in before you can comment on or make changes to this bug.
Description vi0xrhvpa 2015-01-06 13:04:42 UTC
Hi everyone,

POSIX.1-2008 mandates the function declaration of the iconv() function to look like this:

size_t iconv(iconv_t cd, char **restrict inbuf,
       size_t *restrict inbytesleft, char **restrict outbuf,
       size_t *restrict outbytesleft);

(see http://pubs.opengroup.org/onlinepubs/9699919799/functions/iconv.html ).

However, the actual function declared in /usr/include/iconv.h is declared as follows:

size_t iconv(iconv_t, const char ** __restrict,
             size_t * __restrict, char ** __restrict,
             size_t * __restrict);

Notice the `const` qualifier in the declaration of the second parameter, which shouldn’t be there as per POSIX. This causes programs using the iconv() function as per POSIX (without the `const` qualifier) to fail compilation.

Even worse, the documentation of iconv() in form of the iconv(3) manpage also contains the POSIX declaration, which is in conflict with the actual declaration in the header file. That is, the documentation is correct, but declaration in the header file differs from the manpage.

Output of $ uname -a in case it’s required:

  $ uname -a
  FreeBSD bsdtest.quintilianus.eu 10.1-RELEASE FreeBSD 10.1-RELEASE #0 r274401: Tue Nov 11 21:02:49 UTC 2014 root@releng1.nyi.freebsd.org:/usr/obj/usr/src/sys/GENERIC amd64

Comment 1 Marcin Cieślak 2015-07-05 20:33:57 UTC
I think this got "fixed" in https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=199099

Is this a duplicate now?
Comment 2 Tijl Coosemans freebsd_committer 2015-07-06 15:03:03 UTC

*** This bug has been marked as a duplicate of bug 199099 ***