From: Bruno Haible <bruno@clisp.org>
To: cygwin@cygwin.com
Subject: an mbrtoc32 bug
Date: Thu, 23 May 2024 22:16:35 +0200 [thread overview]
Message-ID: <6004047.n2Wp99KBFH@nimes> (raw)
[-- Attachment #1: Type: text/plain, Size: 374 bytes --]
In Cygwin 3.5.3, the attached program has an assertion failure in line 24:
bytes is not (size_t)-2.
How to reproduce:
$ gcc -Wall foo.c
$ ./a
I think this is a bug, because
- ISO C 23 § 7.30.1.5 talks about "completing" a character, not
"representing" an (entire) character.
- The test passes on glibc, musl libc, FreeBSD 14.0, Solaris 11.4.
Bruno
[-- Attachment #2: foo.c --]
[-- Type: text/x-csrc, Size: 766 bytes --]
#include <assert.h>
#include <locale.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <uchar.h>
#include <wchar.h>
int main ()
{
assert (setlocale (LC_ALL, "en_US.UTF-8") != NULL);
mbstate_t state;
memset (&state, 0, sizeof (state));
char32_t uc = 0xDEADBEEF;
size_t bytes;
/* \360\237\220\203 = U+0001F403 */
bytes = mbrtoc32 (&uc, "\360", 1, &state);
assert (bytes == (size_t)-2);
bytes = mbrtoc32 (&uc, "\237", 1, &state);
assert (bytes == (size_t)-2);
bytes = mbrtoc32 (&uc, "\220", 1, &state);
assert (bytes == (size_t)-2);
bytes = mbrtoc32 (&uc, "\203", 1, &state);
assert (bytes == 1);
assert (uc == 0x0001F403);
}
/* Works in: glibc, musl libc, FreeBSD 14.0, Solaris 11.4
Fails in: Cygwin 3.5.3
*/
next reply other threads:[~2024-05-23 20:16 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-23 20:16 Bruno Haible [this message]
2024-05-23 21:31 ` Bruno Haible
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=6004047.n2Wp99KBFH@nimes \
--to=bruno@clisp.org \
--cc=cygwin@cygwin.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).