Closed Bug 1880008 Opened 9 months ago Closed 9 months ago

Add char8_t string overloads to MFBT string functions when compiling with -std=c++20

Categories

(Core :: MFBT, task, P3)

task

Tracking

()

RESOLVED FIXED
124 Branch
Tracking Status
firefox-esr115 --- disabled
firefox122 --- disabled
firefox123 --- disabled
firefox124 --- fixed

People

(Reporter: cpeterson, Assigned: cpeterson)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

When compiled with -std=c++17, u8"" string literals have type const char[]. When compiled with -std=c++20, u8"" string literals have type const char8_t[]. This patch adds the minimum char8_t overloads needed to compile Firefox with -std=c++20. If we want to use char8_t in more code or replace Utf8Unit with char8_t, that will require an extensive redesign of MFBT's and xpcom's string classes after we update from -std=c++17 to c++20.

obj-aarch64-unknown-linux-android/dist/include/mozilla/Utf8.h:473:20: error: call to constructor of 'const Utf8Unit' is ambiguous
| const Utf8Unit unit(*(*aIter)++);

mfbt/tests/TestUtf8.cpp:52:25: error: call to 'IsAscii' is ambiguous
| MOZ_RELEASE_ASSERT(!IsAscii(aStart[0]));

xpcom/tests/gtest/TestStrings.cpp:1446:17: error: no matching member function for call to 'Equals'
| EXPECT_TRUE(s.Equals(u8"\uFFFD"));

When compiled with -std=c++17, u8"" string literals have type const char[]. When compiled with -std=c++20, u8"" string literals have type const char8_t[]. This patch adds the minimum char8_t overloads needed to compile Firefox with -std=c++20. If we want to use char8_t in more code or replace Utf8Unit with char8_t, that will require an extensive redesign of MFBT's and xpcom's string classes after we update from -std=c++17 to c++20.

Blocks: 1426909
Blocks: C++20
See Also: → 1880204
Pushed by cpeterson@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/aaaa3f2b8fed Add char8_t string overloads to MFBT string functions when compiling with -std=c++20. r=xpcom-reviewers,emilio
Status: NEW → RESOLVED
Closed: 9 months ago
Resolution: --- → FIXED
Target Milestone: --- → 124 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: