[LLVMbugs] [Bug 8856] New: clang++ -fshort-wchar results in a signed wchar_t instead of unsigned

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Sat Dec 25 13:13:44 PST 2010


http://llvm.org/bugs/show_bug.cgi?id=8856

           Summary: clang++ -fshort-wchar results in a signed wchar_t
                    instead of unsigned
           Product: clang
           Version: trunk
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: ambrop7 at gmail.com
                CC: llvmbugs at cs.uiuc.edu, dgregor at apple.com


Using the -fshort-wchar option in clang++ seems to result a signed 16-bit
wchar_t. But it should be unsigned (as in gcc, g++ and clang (C mode)).
Test (based on a problematic configure test in XULRunner):

#include <stddef.h>
#include <stdio.h>

int main() {
    if ((wchar_t)-1 > (wchar_t)0) {
        printf("unsigned %d\n", (int)sizeof(wchar_t));
    } else {
        printf("signed %d\n", (int)sizeof(wchar_t));
    }
    return 0;
}

$ gcc -fshort-wchar -o wchar wchar.c
$ ./wchar
unsigned 2
$ g++ -fshort-wchar -o wchar wchar.cpp
$ ./wchar
unsigned 2

$ clang -fshort-wchar -o wchar wchar.c
$ ./wchar
unsigned 2
$ clang++ -fshort-wchar -o wchar wchar.cpp
$ ./wchar
signed 2

Platform is Linux x86_64 (Gentoo ~amd64).

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list