https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104875
--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The releases/gcc-11 branch has been updated by Jonathan Wakely <r...@gcc.gnu.org>: https://gcc.gnu.org/g:e4b0d0b84b719ea9cd3d0a7b0668cdd8055a07d2 commit r11-10770-ge4b0d0b84b719ea9cd3d0a7b0668cdd8055a07d2 Author: Jonathan Wakely <jwak...@redhat.com> Date: Fri Mar 11 14:52:38 2022 +0000 libstdc++: Fix reading UTF-8 characters for 16-bit targets [PR104875] The current code in read_utf8_code_point assumes that integer promotion will create a 32-bit int, but that's not true for 16-bit targets like msp430 and avr. This changes the intermediate variables used for each octet from unsigned char to char32_t, so that (c << N) works correctly when N > 8. libstdc++-v3/ChangeLog: PR libstdc++/104875 * src/c++11/codecvt.cc (read_utf8_code_point): Use char32_t to hold octets that will be left-shifted. (cherry picked from commit 8f7b7c1495f92c72da154d32317943a2cc276ca8)