ThePhD / future_cxx

Work done today for the glory of tomorrow - or, C and C++ systems programming papers.
https://thephd.dev/portfolio/standard
46 stars 8 forks source link

pXXXX - Initialize unsigned char arrays from char8_t string literal (Defect Report) #31

Closed ThePhD closed 2 years ago

ThePhD commented 3 years ago

This is mostly a patch job to help ease the portability from C++17 to C++20. In short:

const unsigned char str0[] = u8"foo";
const unsigned char str1[] = { u8"foo" };
const unsigned char str2[4] = u8"foo";
const unsigned char str3[4] = { u8"foo" };
const unsigned char str4[2] = u8"foo"; // truncation: still fine
const unsigned char str5[2] = { u8"foo" }; // truncation: still fine

All of these should compile. This will ease portability, and will also reduce compatibility issues between C and C++ since WG14 is looking like it will accept typedef unsigned char char8_t as a typedef in C.

ThePhD commented 2 years ago

This is P2513 - #45