[libcxx-commits] [PATCH] D60950: [libc++][test] Update some wstring_convert tests for MSVC quirks

Casey Carter via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Sun Apr 21 10:33:11 PDT 2019


CaseyCarter created this revision.
CaseyCarter added reviewers: EricWF, mclow.lists, ldionne.
Herald added a subscriber: dexonsmith.

Due to MSVC's decision to encode wchar_t as UTF-16, it rejects wide character/string literals that expect a character value greater than \xffff. The first choice is clearly non-conforming, given that the standard requires wchar_t to be capable of representing all characters in the supported wide character execution sets, but the second is a reasonably sane compromise given the first. Consequently `L'\x40003'`/`L"\x40003"` are ill-formed literals, `L'\U00040003'` is a high surrogate (and produces a warning about ignoring the "second character" in a multi-character literal, and `L"\U00040003"` is a perfectly-valid `const wchar_t[3]`.

This change updates these tests to use universal-character-names instead of raw values for the intended character values, which technically makes them portable even to implementations that don't use a unicode transformation format encoding for their wide character execution character set. The two-character literal `L"\u1005e"` is awkward - the `e` looks like part of the UCN's hex encoding - but necessary to compile in '03 mode since '03 didn't allow UCNs to be used for members of the basic execution character set even in character/string literals.

I've also eliminated the extraneous `\x00` "bonus null-terminator" in some of the string literals which doesn't affect the tested behavior. I'm sorry about using `*L"\U00040003"` in `conversions.string/to_bytes.pass.cpp`, but it's correct for platforms with 32-bit wchar_t, *and* doesn't trigger narrowing warnings as did the prior `CharT(0x40003)`.


Repository:
  rCXX libc++

https://reviews.llvm.org/D60950

Files:
  test/std/localization/locales/locale.convenience/conversions/conversions.string/converted.pass.cpp
  test/std/localization/locales/locale.convenience/conversions/conversions.string/from_bytes.pass.cpp
  test/std/localization/locales/locale.convenience/conversions/conversions.string/to_bytes.pass.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D60950.196008.patch
Type: text/x-patch
Size: 4828 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20190421/0dc33a19/attachment.bin>


More information about the libcxx-commits mailing list