#15990 closed bug (fixed)
uchar.h defines the types char16_t, char32_t incorrectly
Reported by: | bhaible | Owned by: | nobody |
---|---|---|---|
Priority: | normal | Milestone: | R1/beta2 |
Component: | System/POSIX | Version: | R1/Development |
Keywords: | Cc: | leorize | |
Blocked By: | Blocking: | ||
Platform: | All |
Description
Seen in hrev54131 (2020-05-04).
The ISO C 11 standard, section 7.28, specifies that
- char16_t must be an unsigned type, equivalent to uint_least16_t (defined in <stdint.h>),
- char32_t must be an unsigned type, equivalent to uint_least32_t (defined in <stdint.h>).
The attached test program foo.c verifies this. The expected output is:
char16_t is unsigned? 1 char32_t is unsigned? 1 char16_t is as wide as uint_least16_t? 1 char32_t is as wide as uint_least32_t? 1
On Haiku/x86_64, different bugs are observed in C and C++ mode.
1) In C mode:
$ gcc foo.c $ ./a.out char16_t is unsigned? 0 char32_t is unsigned? 0 char16_t is as wide as uint_least16_t? 0 char32_t is as wide as uint_least32_t? 0
2) In C++ mode: The file does not even compile, due to type conflicts in the inline functions of <uchar.h>.
$ gcc -x c++ foo.c In file included from foo.c:1: /boot/system/develop/headers/posix/uchar.h: In function 'size_t mbrtoc16(char16_t*, const char*, size_t, mbstate_t*)': /boot/system/develop/headers/posix/uchar.h:28:17: error: cannot convert 'char16_t*' to 'wchar_t*' return mbrtowc(dest, src, srcLength, mbState); ^~~~ In file included from /boot/system/develop/headers/posix/uchar.h:8, from foo.c:1: /boot/system/develop/headers/posix/wchar.h:66:33: note: initializing argument 1 of 'size_t mbrtowc(wchar_t*, const char*, size_t, mbstate_t*)' extern size_t mbrtowc(wchar_t *dest, const char *src, size_t srcLength, ~~~~~~~~~^~~~ In file included from foo.c:1: /boot/system/develop/headers/posix/uchar.h: In function 'size_t mbrtoc32(char32_t*, const char*, size_t, mbstate_t*)': /boot/system/develop/headers/posix/uchar.h:39:17: error: invalid conversion from 'char32_t*' to 'wchar_t*' [-fpermissive] return mbrtowc(dest, src, srcLength, mbState); ^~~~ In file included from /boot/system/develop/headers/posix/uchar.h:8, from foo.c:1: /boot/system/develop/headers/posix/wchar.h:66:33: note: initializing argument 1 of 'size_t mbrtowc(wchar_t*, const char*, size_t, mbstate_t*)' extern size_t mbrtowc(wchar_t *dest, const char *src, size_t srcLength, ~~~~~~~~~^~~~
Attachments (3)
Change History (16)
by , 5 years ago
comment:1 by , 5 years ago
Component: | - General → System/libroot.so |
---|
comment:2 by , 5 years ago
Component: | System/libroot.so → System/POSIX |
---|
comment:5 by , 5 years ago
Partial fix: https://review.haiku-os.org/c/haiku/+/2623
I did not fully implement char16_t. Do we really need it?
comment:7 by , 5 years ago
As far as I can see, this header is not used and EFI has its own definition for it.
comment:8 by , 5 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Fix merged, but NOT backported to r1beta2 (for now).
comment:9 by , 5 years ago
The new uchar.h defines the function mbrtoc32 twice. I would guess that this produces a compilation error, both in C mode and in C++ mode. No?
comment:12 by , 5 years ago
Assign tickets with status=closed and resolution=fixed within the R1/beta2 development window to the R1/beta2 Milestone
comment:13 by , 5 years ago
Milestone: | Unscheduled → R1/beta2 |
---|
test program