You are not logged in.
Pages: 1
Hi
I'm having an issue when running the following program:
#include <wchar.h>
int main() {
mbstate_t mbs;
mbrlen (NULL,0,&mbs);
}
After compiling with gcc, the program aborts from an assertion internally inside the glibc function __mbrtowc
./a.out
a.out: mbrtowc.c:103: __mbrtowc: Assertion `((data.__statep)->__count == 0)' failed.
Aborted
The assertion seems testing if the struct mbstate_t object has been set to the initial state after a call to gconv.
The program works fine if compiled with clang.
Here is some system information:
~ pacman -Q glibc gcc
glibc 2.19-5
gcc 4.9.0-5
~ locale -a
C
en_CA.utf8
POSIX
~ locale
LANG=en_CA.UTF-8
LC_CTYPE="en_CA.UTF-8"
LC_NUMERIC="en_CA.UTF-8"
LC_TIME="en_CA.UTF-8"
LC_COLLATE="en_CA.UTF-8"
LC_MONETARY="en_CA.UTF-8"
LC_MESSAGES="en_CA.UTF-8"
LC_PAPER="en_CA.UTF-8"
LC_NAME="en_CA.UTF-8"
LC_ADDRESS="en_CA.UTF-8"
LC_TELEPHONE="en_CA.UTF-8"
LC_MEASUREMENT="en_CA.UTF-8"
LC_IDENTIFICATION="en_CA.UTF-8"
LC_ALL=
Testing the same program with LC_ALL="C" and LC_ALL="POSIX" both produce the same error.
I tested this program on a friend's RedHat installation, and it worked fine (I can collect more system information later if relevant).
From here I don't know where to look / who to ask. Any advice would be greatly appreciated.
Offline
Offline
The c standards do not define the result of calling mbrlen or mbrtowc with an uninitialized state. Maybe clang defaults to setting new structures to zero, while gcc does not. This works:
Edit: The problem may very well be inside the gconv modules, the mbr functions look fine to me.
#include <wchar.h>
#include <string.h>
int main() {
mbstate_t mbs;
memset(&mbs, 0, sizeof(mbs)); // initialize
mbrlen (NULL,0,&mbs);
}
Last edited by progandy (2014-07-18 00:04:31)
| alias CUTF='LANG=en_XX.UTF-8@POSIX ' |
Offline
Pages: 1