On OSF/1 5.1, I'm seeing this gcc warning: wcsrtombs.c: In function 'rpl_wcsrtombs': wcsrtombs.c:44: warning: passing argument 4 of 'wcsrtombs' from incompatible pointer type
The reason is that wcsrtombs exists but mbstate_t and mbsinit() are replaced by gnulib. gnulib is passing an rpl_mbstate_t (of size 4) to a function that expects an mbstate_t (of size 12). Although wcsrtombs usually cannot put this object into a non-initial state, passing an object of size 4 can still lead to SIGSEGV due to out-of-range memory accesses. This fixes it: 2010-12-20 Bruno Haible <br...@clisp.org> wcsrtombs: Don't confuse mbstate_t with rpl_mbstate_t. * lib/wcsrtombs.c: If gnulib overrides mbstate_t, define wcsrtombs through wcrtomb. --- lib/wcsrtombs.c.orig Mon Dec 20 11:15:06 2010 +++ lib/wcsrtombs.c Mon Dec 20 11:08:55 2010 @@ -1,5 +1,5 @@ /* Convert wide string to string. - Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc. + Copyright (C) 2008, 2010 Free Software Foundation, Inc. Written by Bruno Haible <br...@clisp.org>, 2008. This program is free software: you can redistribute it and/or modify @@ -22,7 +22,7 @@ extern mbstate_t _gl_wcsrtombs_state; -#if HAVE_WCSRTOMBS && !WCSRTOMBS_TERMINATION_BUG +#if HAVE_WCSRTOMBS && !WCSRTOMBS_TERMINATION_BUG && !defined GNULIB_defined_mbstate_t /* Override the system's wcsrtombs() function. */ # undef wcsrtombs