[LLVMbugs] [Bug 11733] New: static_assert on Unicode string literals seems to get wrong values

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon Jan 9 17:36:16 PST 2012


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

             Bug #: 11733
           Summary: static_assert on Unicode string literals seems to get
                    wrong values
           Product: clang
           Version: trunk
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++0x
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: seth.cantrell at gmail.com
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    Classification: Unclassified


The code:

static_assert(u8"\U0001F306"[0] == 0xF0, "The UTF-8 encoding of U+1F306 should
be F0 9F 8C 86");

Results in the diagnostic:

error: static_assert failed "The UTF-8 encoding of U+1F306 should be F0 9F 8C
86"
    static_assert(u8"\U0001F306"[0] == 0xF0,
    ^             ~~~~~~~~~~~~~~~~~~~~~~~~~
Whereas the code:

    char const *s = u8"\U0001F306";

Produces the IR

@.str = private unnamed_addr constant [5 x i8] c"\F0\9F\8C\86\00", align 1

Clang is producing the correct string encoding for the IR, but this is not
reflected in the static_assert evaluation of the string literal. I'm not sure
exactly what value static_assert believes the string literal to contain.

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