<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>299535</bug_id>
          
          <creation_ts>2025-09-25 11:02:23 -0700</creation_ts>
          <short_desc>Many -Wcharacter-conversion warnings with Clang 21</short_desc>
          <delta_ts>2025-09-29 13:14:22 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>Web Template Framework</component>
          <version>WebKit Nightly Build</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>DUPLICATE</resolution>
          <dup_id>299689</dup_id>
          <see_also>https://bugs.webkit.org/show_bug.cgi?id=299720</see_also>
    
    <see_also>https://bugs.webkit.org/show_bug.cgi?id=299689</see_also>
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Michael Catanzaro">mcatanzaro</reporter>
          <assigned_to name="Michael Catanzaro">mcatanzaro</assigned_to>
          <cc>kkinnunen</cc>
    
    <cc>mcatanzaro</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>2145903</commentid>
    <comment_count>0</comment_count>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2025-09-25 11:02:23 -0700</bug_when>
    <thetext>For example:

/home/mcatanzaro/Projects/WebKit/Source/WTF/wtf/text/StringConcatenate.h:112:30: error: implicit conversion from &apos;const char32_t&apos; to &apos;element_type&apos; (aka &apos;char16_t&apos;) may lose precision and change the meaning of the represented code unit [-Werror,-Wcharacter-conversion]
  112 |             destination[0] = m_character;
      |                            ~ ^~~~~~~~~~~
1 error generated.

/home/mcatanzaro/Projects/WebKit/Source/WTF/wtf/URLHelpers.cpp:174:61: error: implicit conversion from &apos;char16_t&apos; to &apos;char32_t&apos; may change the meaning of the represented code unit [-Werror,-Wcharacter-conversion]
  174 |         return isLookalikeCharacterOfScriptType&lt;ScriptType&gt;(first) &amp;&amp; !(isOfScriptType&lt;ScriptType&gt;(second) || isASCIIDigitOrValidHostCharacter(second));
      |                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~             ^~~~~

/home/mcatanzaro/Projects/WebKit/Source/WTF/wtf/URLHelpers.cpp:177:48: error: implicit conversion from &apos;char32_t&apos; to &apos;char16_t&apos; may lose precision and change the meaning of the represented code unit [-Werror,-Wcharacter-conversion]
  177 |         || isLookalikePair(*previousCodePoint, codePoint);
      |            ~~~~~~~~~~~~~~~                     ^~~~~~~~~
/home/mcatanzaro/Projects/WebKit/Source/WTF/wtf/URLHelpers.cpp:350:16: note: in instantiation of function template specialization &apos;WTF::URLHelpers::isLookalikeSequence&lt;USCRIPT_ARMENIAN&gt;&apos; requested here
  350 |         return isLookalikeSequence&lt;USCRIPT_ARMENIAN&gt;(previousCodePoint, codePoint)
      |                ^

Worse, several of these are coming from ICU headers:

/home/mcatanzaro/Projects/WebKit/Source/WTF/wtf/text/StringView.h:1017:5: error: implicit conversion from &apos;const char16_t&apos; to &apos;char32_t&apos; may change the meaning of the represented code unit [-Werror,-Wcharacter-conversion]
 1017 |     U16_GET(static_cast&lt;const char16_t*&gt;(m_current), 0, 0, length, codePoint);
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/unicode/utf16.h:202:9: note: expanded from macro &apos;U16_GET&apos;
  202 |     (c)=(s)[i]; \
      |        ~^~~~~~</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2145904</commentid>
    <comment_count>1</comment_count>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2025-09-25 11:11:09 -0700</bug_when>
    <thetext>Fixing ICU is pretty easy:

diff --git a/icu4c/source/common/unicode/utf16.h b/icu4c/source/common/unicode/utf16.h
index 3902c60e95e..43e72a711cc 100644
--- a/icu4c/source/common/unicode/utf16.h
+++ b/icu4c/source/common/unicode/utf16.h
@@ -165,7 +165,7 @@
  * @stable ICU 2.4
  */
 #define U16_GET_UNSAFE(s, i, c) UPRV_BLOCK_MACRO_BEGIN { \
-    (c)=(s)[i]; \
+    (c)=(UChar32)(s)[i]; \
     if(U16_IS_SURROGATE(c)) { \
         if(U16_IS_SURROGATE_LEAD(c)) { \
             (c)=U16_GET_SUPPLEMENTARY((c), (s)[(i)+1]); \
@@ -199,7 +199,7 @@
  * @stable ICU 2.4
  */
 #define U16_GET(s, start, i, length, c) UPRV_BLOCK_MACRO_BEGIN { \
-    (c)=(s)[i]; \
+    (c)=(UChar32)(s)[i]; \
     if(U16_IS_SURROGATE(c)) { \
         uint16_t __c2; \
         if(U16_IS_SURROGATE_LEAD(c)) { \
@@ -238,7 +238,7 @@
  * @stable ICU 60
  */
 #define U16_GET_OR_FFFD(s, start, i, length, c) UPRV_BLOCK_MACRO_BEGIN { \
-    (c)=(s)[i]; \
+    (c)=(UChar32)(s)[i]; \
     if(U16_IS_SURROGATE(c)) { \
         uint16_t __c2; \
         if(U16_IS_SURROGATE_LEAD(c)) { \
@@ -279,7 +279,7 @@
  * @stable ICU 2.4
  */
 #define U16_NEXT_UNSAFE(s, i, c) UPRV_BLOCK_MACRO_BEGIN { \
-    (c)=(s)[(i)++]; \
+    (c)=(UChar32)(s)[(i)++]; \
     if(U16_IS_LEAD(c)) { \
         (c)=U16_GET_SUPPLEMENTARY((c), (s)[(i)++]); \
     } \
@@ -307,7 +307,7 @@
  * @stable ICU 2.4
  */
 #define U16_NEXT(s, i, length, c) UPRV_BLOCK_MACRO_BEGIN { \
-    (c)=(s)[(i)++]; \
+    (c)=(UChar32)(s)[(i)++]; \
     if(U16_IS_LEAD(c)) { \
         uint16_t __c2; \
         if((i)!=(length) &amp;&amp; U16_IS_TRAIL(__c2=(s)[(i)])) { \
@@ -339,7 +339,7 @@
  * @stable ICU 60
  */
 #define U16_NEXT_OR_FFFD(s, i, length, c) UPRV_BLOCK_MACRO_BEGIN { \
-    (c)=(s)[(i)++]; \
+    (c)=(UChar32)(s)[(i)++]; \
     if(U16_IS_SURROGATE(c)) { \
         uint16_t __c2; \
         if(U16_IS_SURROGATE_LEAD(c) &amp;&amp; (i)!=(length) &amp;&amp; U16_IS_TRAIL(__c2=(s)[(i)])) { \


However, unfortunately ICU has a contributor license agreement, which I&apos;m not going to accept, so I won&apos;t submit this to upstream. We need to work around this at the WebKit level anyway since we only control the ICU headers on macOS; on Linux, they are a system dependency.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2145919</commentid>
    <comment_count>2</comment_count>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2025-09-25 12:20:08 -0700</bug_when>
    <thetext>Unrelated:

/home/mcatanzaro/Projects/WebKit/WebKitBuild/gtk4/JavaScriptCore/PrivateHeaders/JavaScriptCore/RemoteInspector.h:135:13: error: virtual method &apos;~RemoteInspector&apos; is inside a &apos;final&apos; class and can never be overridden [-Werror,-Wunnecessary-virtual-specifier]
  135 |     virtual ~RemoteInspector();
      |             ^
1 error generated.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2146870</commentid>
    <comment_count>3</comment_count>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2025-09-29 10:00:35 -0700</bug_when>
    <thetext>Darin says: &quot;I reviewed ICU documentation, and I think it’s an error to use U16_GET with char32_t. The output type is supposed to be uint32_t. So that’s why ICU won’t be fixing it!&quot; Well, the actual output type is UChar32. It should be compatible with char32_t in the sense that casting should do the right thing, but it&apos;s indeed WebKit&apos;s fault for using the wrong type, not an ICU bug. So no need for anybody to try submitting my patch to ICU.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2146930</commentid>
    <comment_count>4</comment_count>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2025-09-29 13:08:56 -0700</bug_when>
    <thetext>Another note for myself:

/home/mcatanzaro/Projects/WebKit/Source/WebKit/UIProcess/AuxiliaryProcessProxy.cpp:166:10: error: variable &apos;varname&apos; is used uninitialized whenever switch case is taken [-Werror,-Wsometimes-uninitialized]
  166 |     case ProcessLauncher::ProcessType::DBusProxy:
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/mcatanzaro/Projects/WebKit/Source/WebKit/UIProcess/AuxiliaryProcessProxy.cpp:171:43: note: uninitialized use occurs here
  171 |     const char* processCmdPrefix = getenv(varname);
      |                                           ^~~~~~~
/home/mcatanzaro/Projects/WebKit/Source/WebKit/UIProcess/AuxiliaryProcessProxy.cpp:147:24: note: initialize the variable &apos;varname&apos; to silence this warning
  147 |     const char* varname;
      |                        ^
      |                         = nullptr</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2146936</commentid>
    <comment_count>5</comment_count>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2025-09-29 13:14:22 -0700</bug_when>
    <thetext>

*** This bug has been marked as a duplicate of bug 299689 ***</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>