[llvm-bugs] [Bug 38582] New: u8 character literal prefix in C

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Aug 15 11:38:24 PDT 2018


https://bugs.llvm.org/show_bug.cgi?id=38582

            Bug ID: 38582
           Summary: u8 character literal prefix in C
           Product: clang
           Version: unspecified
          Hardware: Macintosh
                OS: MacOS X
            Status: NEW
          Severity: normal
          Priority: P
         Component: Frontend
          Assignee: unassignedclangbugs at nondot.org
          Reporter: Bumblebritches57 at gmail.com
                CC: llvm-bugs at lists.llvm.org

I'm using Xcode 10 Beta 5, AND Xcode 9.3.1, so I'm not sure what version of
clang I'm using because Apple's version numbers are different from the rest of
the LLVM projects version numbers.

This problem has been ongoing.

C11 and C17 both support using u8'X' (or u8'\uXXXX' or u8'\UXXXXXXXX') as
character literal prefixes to specify that the literal should be encoded as
UTF-8.

Don't get me wrong, u8"X", u8"\uXXXX", and u8"\UXXXXXXXX" STRING literals work
fine, but character literals do not.

Here's an example program for you to test:

    #include <stdio.h>
    #include <stdint.h>

    int main(int argc, const char * argv[]) {
        uint8_t UTF8CharacterLiteral   = u8'X';
        uint8_t UTF8Hex4Literal        = u8'\u0304';
        uint8_t UTF8Hex8Literal        = u8'\U00000304';
        printf("UTF-8 Literals: %c, %c, %c", UTF8CharacterLiteral,
UTF8Hex4Literal, UTF8Hex8Literal);

        uint16_t UTF16CharacterLiteral = u'X';
        uint16_t UTF16Hex4Literal      = u'\u0304';
        uint16_t UTF16Hex8Literal      = u'\U00000304';
        printf("UTF-16 Literals: %c, %c, %c", UTF16CharacterLiteral,
UTF16Hex4Literal, UTF16Hex8Literal);

        uint32_t UTF32CharacterLiteral = U'X';
        uint32_t UTF32Hex4Literal      = U'\u0304';
        uint32_t UTF32Hex8Literal      = U'\U00000304';
        printf("UTF-32 Literals: %c, %c, %c", UTF32CharacterLiteral,
UTF32Hex4Literal, UTF32Hex8Literal);
        return 0;
}

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20180815/2e806d63/attachment.html>


More information about the llvm-bugs mailing list