ygrek / mldonkey

cross-platform multi-network p2p daemon (previously at http://mldonkey.sourceforge.net/)
Other
247 stars 46 forks source link

GCC 14: Fix incompatible pointer type in charsetstubs.c #92

Closed chusopr closed 2 months ago

chusopr commented 9 months ago

The ml_iconv function in charsetstubs.c was passing a const char ** input buffer to iconv, but iconv expects a char **.

GCC 14 fails when passing that incompatible pointer type:

src/utils/lib/charsetstubs.c: In function ‘ml_iconv’:
src/utils/lib/charsetstubs.c:1207:23: error: passing argument 2 of ‘iconv’ from incompatible pointer type [-Wincompatible-pointer-types]
 1207 |     return iconv (cd, inbuf, inbytes_left, outbuf, outbytes_left);
      |                       ^~~~~
      |                       |
      |                       const char **
In file included from src/utils/lib/charsetstubs.c:45:
/usr/include/iconv.h:49:54: note: expected ‘char ** restrict’ but argument is of type ‘const char **’
   49 | extern size_t iconv (iconv_t __cd, char **__restrict __inbuf,
      |                                    ~~~~~~~~~~~~~~~~~~^~~~~~~

Downstream bug: https://bugs.gentoo.org/921257

ygrek commented 3 months ago

as I have learned there are two incompatible iconv out there https://stackoverflow.com/questions/45938990/why-does-the-iconv-function-need-a-non-const-inbuffer but afaiu with the proposed change it should compile on both

FabioLolix commented 2 months ago

Confirming this work for Arch Linux