[LLVMbugs] [Bug 12588] New: Wide character literal has wrong size when cross-compiling

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed Apr 18 09:22:05 PDT 2012


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

             Bug #: 12588
           Summary: Wide character literal has wrong size when
                    cross-compiling
           Product: clang
           Version: 3.0
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: shea at shealevy.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified


>From C99, section 6.4.4.4:

"A wide character constant has type wchar_t, an integer type deļ¬ned in the
<stddef.h> header."

However, the following program does not always return the expected 1:

#include <stddef.h>
int main() {
    return (sizeof(wchar_t) == sizeof L'\0');
}

In particular, when compiling on x86-64 Linux targeting Linux this works as
expected, and when compiling on x86-64 Windows targeting Windows it also works.
Compiling the program with '-ccc-host-triple x86_64-pc-win32-coff' on Linux,
however, produces an object file that will return 0, and further investigation
shows that the size of L'\0' is 4 (incorrect) and the size of wchar_t is 2
(expected). Moreover, in the cross-compilation environment the type of L"" is
"unsigned short[1]" but the type of L'\0' is "int".

-- 
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