Hi! I've committed earlier today https://gcc.gnu.org/r16-5628 to switch C++ to -std=gnu++20 by default. That apparently broke rust build (I don't have cargo installed, so am not testing rust at all).
Here is a completely untested attempt to fix that. Note, in C++20 u8"abc" literal has const char8_t[4] type rather than const char[4] which was the case in C++17, and there is std::u8string etc. The casts below to (const char *) is what I've used in libcody as well to make it compilable with all of C++11 to C++26. Another thing is that the source for some reason expects -fexec-charset= to be ASCII compatible and -fwide-exec-charset= to be UTF-16 or UTF-32 or something similar. That is certainly not guaranteed. Now, if rust-lex.cc can be only compiled with C++17 or later, we could just use u8'_' etc., but as GCC still only requires C++14, I'd go with u'_' etc. 2025-11-26 Jakub Jelinek <[email protected]> * lex/rust-lex.cc (rust_input_source_test): Cast char8_t string literals to (const char *) to make it compilable with C++20. Use char16_t character literals instead of ordinary character literals or wide character literals in expected initializers. --- gcc/rust/lex/rust-lex.cc.jj 2025-10-30 22:37:10.217676928 +0100 +++ gcc/rust/lex/rust-lex.cc 2025-11-26 19:33:39.621553271 +0100 @@ -2639,37 +2639,37 @@ void rust_input_source_test () { // ASCII - std::string src = u8"_abcde\tXYZ\v\f"; + std::string src = (const char *) u8"_abcde\tXYZ\v\f"; std::vector<uint32_t> expected - = {'_', 'a', 'b', 'c', 'd', 'e', '\t', 'X', 'Y', 'Z', '\v', '\f'}; + = {u'_', u'a', u'b', u'c', u'd', u'e', u'\t', u'X', u'Y', u'Z', u'\v', u'\f'}; test_buffer_input_source (src, expected); // BOM - src = u8"\xef\xbb\xbfOK"; - expected = {'O', 'K'}; + src = (const char *) u8"\xef\xbb\xbfOK"; + expected = {u'O', u'K'}; test_buffer_input_source (src, expected); // Russian - src = u8"приве́т"; - expected = {L'п', - L'р', - L'и', - L'в', + src = (const char *) u8"приве́т"; + expected = {u'п', + u'р', + u'и', + u'в', 0x0435 /* CYRILLIC SMALL LETTER IE е */, 0x301 /* COMBINING ACUTE ACCENT ́ */, - L'т'}; + u'т'}; test_buffer_input_source (src, expected); - src = u8"❤️🦀"; + src = (const char *) u8"❤️🦀"; expected = {0x2764 /* HEAVY BLACK HEART */, - 0xfe0f /* VARIATION SELECTOR-16 */, L'🦀'}; + 0xfe0f /* VARIATION SELECTOR-16 */, u'🦀'}; test_buffer_input_source (src, expected); - src = u8"こんにちは"; - expected = {L'こ', L'ん', L'に', L'ち', L'は'}; + src = (const char *) u8"こんにちは"; + expected = {u'こ', u'ん', u'に', u'ち', u'は'}; test_file_input_source (src, expected); - src = u8"👮♂👩⚕"; + src = (const char *) u8"👮♂👩⚕"; expected = {0x1f46e /* POLICE OFFICER */, 0x200d /* ZERO WIDTH JOINER */, 0x2642 /* MALE SIGN */, 0x1f469 /* WOMAN */, Jakub
