Bug 196540

Summary: iconv() function violates POSIX
Product: Base System Reporter: devnull <ACCOUNT_DELETED>
Component: standardsAssignee: freebsd-standards (Nobody) <standards>
Status: Closed DUPLICATE    
Severity: Affects Some People CC: ACCOUNT_DELETED, saper
Priority: ---    
Version: 10.1-RELEASE   
Hardware: Any   
OS: Any   

Description devnull freebsd_committer freebsd_triage 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

Greetings,
Marvin
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 freebsd_triage 2015-07-06 15:03:03 UTC

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