From 62eb042a11f4e7910b08c6649c1d078abeaef525 Mon Sep 17 00:00:00 2001
From: Mike Hommey <mh+mozilla@glandium.org>
Date: Thu, 17 Aug 2023 05:37:11 +0000
Subject: [PATCH] Bug 1849070 - Avoid using char_traits<unsigned char>.
 r=spidermonkey-reviewers,anba

It is not guaranteed to exist by the standard, and is actively being
removed from libc++ in LLVM 18.

Differential Revision: https://phabricator.services.mozilla.com/D186421
---
 js/src/builtin/intl/Locale.cpp | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/js/src/builtin/intl/Locale.cpp b/js/src/builtin/intl/Locale.cpp
index b7bdfa4f275a4..d93f1e62a29c8 100644
--- js/src/builtin/intl/Locale.cpp
+++ js/src/builtin/intl/Locale.cpp
@@ -801,8 +801,10 @@ static inline auto FindUnicodeExtensionType(JSLinearString* unicodeExtension,
                                             UnicodeKey key) {
   JS::AutoCheckCannotGC nogc;
   return unicodeExtension->hasLatin1Chars()
-             ? FindUnicodeExtensionType(unicodeExtension->latin1Chars(nogc),
-                                        unicodeExtension->length(), key)
+             ? FindUnicodeExtensionType(
+                   reinterpret_cast<const char*>(
+                       unicodeExtension->latin1Chars(nogc)),
+                   unicodeExtension->length(), key)
              : FindUnicodeExtensionType(unicodeExtension->twoByteChars(nogc),
                                         unicodeExtension->length(), key);
 }
@@ -919,7 +921,9 @@ static BaseNamePartsResult BaseNameParts(const CharT* baseName, size_t length) {
 static inline auto BaseNameParts(JSLinearString* baseName) {
   JS::AutoCheckCannotGC nogc;
   return baseName->hasLatin1Chars()
-             ? BaseNameParts(baseName->latin1Chars(nogc), baseName->length())
+             ? BaseNameParts(
+                   reinterpret_cast<const char*>(baseName->latin1Chars(nogc)),
+                   baseName->length())
              : BaseNameParts(baseName->twoByteChars(nogc), baseName->length());
 }
 
