[PATCH] D127363: [Lex] Fix for char32_t literal truncation on 16 bit architectures

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jun 9 08:08:48 PDT 2022


aaron.ballman added a comment.

In D127363#3570169 <https://reviews.llvm.org/D127363#3570169>, @sammccall wrote:

> In D127363#3570150 <https://reviews.llvm.org/D127363#3570150>, @aaron.ballman wrote:
>
>>> On 16 bit architectures char32_t literals are truncated, for example U'\U00064321' will be truncated to 0x4321.
>>
>> Is that valid?
>>
>> https://eel.is/c++draft/basic.types#basic.fundamental-9.sentence-2 and also C2x 7.29p2 (which has the same underlying type requirement) both say that the underlying type for `char32_t` is `uint_least32_t`. Adding @tahonermann to verify.
>
> I think Sebastian is describing the current broken behavior that this patch fixes.
> So if you're saying "that sounds wrong" then I think we're all in agreement :-)
>
> (Sorry if I'm misreading either Sebastian's comment or yours).

Oh! I hadn't read it that way initially! But yes, I'm saying "this behavior sounds wrong and should be corrected." I misread the code and missed that it was fixing in the correct direction. :-)

I think this should have a test, and we can probably use `_Static_assert` for it: https://godbolt.org/z/611bx47qc


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D127363/new/

https://reviews.llvm.org/D127363



More information about the cfe-commits mailing list