<?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>241516</bug_id>
          
          <creation_ts>2022-06-10 11:22:42 -0700</creation_ts>
          <short_desc>-Wmismatched-new-delete warning spam from CSSStyleValue.h</short_desc>
          <delta_ts>2022-11-13 19:06:09 -0800</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>CSS</component>
          <version>WebKit Nightly Build</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          <see_also>https://bugs.webkit.org/show_bug.cgi?id=247873</see_also>
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</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>cdumez</cc>
    
    <cc>lmoura</cc>
    
    <cc>mcatanzaro</cc>
    
    <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1875273</commentid>
    <comment_count>0</comment_count>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2022-06-10 11:22:42 -0700</bug_when>
    <thetext>Unfortunately since this is a header file, it triggers a massive warning spam that exceeds my terminal scrollback. 
Sadly, I won&apos;t notice other compiler warnings until it is fixed:

In destructor ‘virtual WebCore::CSSStyleValue::~CSSStyleValue()’,
    inlined from ‘void std::default_delete&lt;_Tp&gt;::operator()(_Tp*) const [with _Tp = WebCore::CSSStyleValue]’ at /usr/include/c++/12/bits/unique_ptr.h:95:2,
    inlined from ‘void WTF::RefCounted&lt;T, Deleter&gt;::deref() const [with T = WebCore::CSSStyleValue; Deleter = std::default_delete&lt;WebCore::CSSStyleValue&gt;]’ at /home/mcatanzaro/Projects/WebKit/WebKitBuild/GNOME-gtk3/WTF/Headers/wtf/RefCounted.h:190:22,
    inlined from ‘void WTF::RefCounted&lt;T, Deleter&gt;::deref() const [with T = WebCore::CSSStyleValue; Deleter = std::default_delete&lt;WebCore::CSSStyleValue&gt;]’ at /home/mcatanzaro/Projects/WebKit/WebKitBuild/GNOME-gtk3/WTF/Headers/wtf/RefCounted.h:187:10,
    inlined from ‘WTF::Ref&lt;T, &lt;template-parameter-1-2&gt; &gt;::~Ref() [with T = WebCore::CSSUnitValue; Traits = WTF::RawPtrTraits&lt;WebCore::CSSUnitValue&gt;]’ at /home/mcatanzaro/Projects/WebKit/WebKitBuild/GNOME-gtk3/WTF/Headers/wtf/Ref.h:61:23,
    inlined from ‘JSC::EncodedJSValue WebCore::jsDOMCSSNamespaceConstructorFunction_chBody(JSC::JSGlobalObject*, JSC::CallFrame*)’ at /home/mcatanzaro/Projects/WebKit/WebKitBuild/GNOME-gtk3/WebCore/DerivedSources/JSDOMCSSNamespace.cpp:1015:5,
    inlined from ‘static JSC::EncodedJSValue WebCore::IDLOperation&lt;JSClass&gt;::callStatic(JSC::JSGlobalObject&amp;, JSC::CallFrame&amp;, const char*) [with JSC::EncodedJSValue (* operation)(JSC::JSGlobalObject*, JSC::CallFrame*) = WebCore::jsDOMCSSNamespaceConstructorFunction_chBody; WebCore::CastedThisErrorBehavior shouldThrow = WebCore::CastedThisErrorBehavior::Throw; JSClass = WebCore::JSDOMCSSNamespace]’ at /home/mcatanzaro/Projects/WebKit/Source/WebCore/bindings/js/JSDOMOperation.h:70:25,
    inlined from ‘JSC::EncodedJSValue WebCore::jsDOMCSSNamespaceConstructorFunction_ch(JSC::JSGlobalObject*, JSC::CallFrame*)’ at /home/mcatanzaro/Projects/WebKit/WebKitBuild/GNOME-gtk3/WebCore/DerivedSources/JSDOMCSSNamespace.cpp:1020:100:
/home/mcatanzaro/Projects/WebKit/Source/WebCore/css/typedom/CSSStyleValue.h:113:13: warning: ‘static void WebCore::CSSStyleValue::operator delete(void*)’ called on pointer returned from a mismatched allocation function [-Wmismatched-new-delete]
  113 |     virtual ~CSSStyleValue() = default;
      |             ^
In static member function ‘static WTF::Ref&lt;WebCore::CSSUnitValue&gt; WebCore::CSSUnitValue::create(double, WebCore::CSSUnitType)’,
    inlined from ‘static WTF::Ref&lt;WebCore::CSSUnitValue&gt; WebCore::CSSNumericFactory::ch(double)’ at /home/mcatanzaro/Projects/WebKit/Source/WebCore/css/typedom/CSSNumericFactory.h:54:104,
    inlined from ‘JSC::EncodedJSValue WebCore::jsDOMCSSNamespaceConstructorFunction_chBody(JSC::JSGlobalObject*, JSC::CallFrame*)’ at /home/mcatanzaro/Projects/WebKit/WebKitBuild/GNOME-gtk3/WebCore/DerivedSources/JSDOMCSSNamespace.cpp:1015:5,
    inlined from ‘static JSC::EncodedJSValue WebCore::IDLOperation&lt;JSClass&gt;::callStatic(JSC::JSGlobalObject&amp;, JSC::CallFrame&amp;, const char*) [with JSC::EncodedJSValue (* operation)(JSC::JSGlobalObject*, JSC::CallFrame*) = WebCore::jsDOMCSSNamespaceConstructorFunction_chBody; WebCore::CastedThisErrorBehavior shouldThrow = WebCore::CastedThisErrorBehavior::Throw; JSClass = WebCore::JSDOMCSSNamespace]’ at /home/mcatanzaro/Projects/WebKit/Source/WebCore/bindings/js/JSDOMOperation.h:70:25,
    inlined from ‘JSC::EncodedJSValue WebCore::jsDOMCSSNamespaceConstructorFunction_ch(JSC::JSGlobalObject*, JSC::CallFrame*)’ at /home/mcatanzaro/Projects/WebKit/WebKitBuild/GNOME-gtk3/WebCore/DerivedSources/JSDOMCSSNamespace.cpp:1020:100:
/home/mcatanzaro/Projects/WebKit/Source/WebCore/css/typedom/CSSUnitValue.h:43:116: note: returned from ‘static void* WebCore::CSSUnitValue::operator new(size_t)’
   43 |     static Ref&lt;CSSUnitValue&gt; create(double value, CSSUnitType unit) { return adoptRef(*new CSSUnitValue(value, unit)); }
      |                                                                                                                    ^

I&apos;m frustrated that I do not see the problem. I think it must be somehow related to the WTF_MAKE_ISO_ALLOCATED, but I&apos;m bamboozled as to what exactly is wrong. I wouldn&apos;t be surprised if GCC is just totally confused.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1875278</commentid>
    <comment_count>1</comment_count>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2022-06-10 11:39:12 -0700</bug_when>
    <thetext>I found a fix, but it makes no sense:

diff --git a/Source/WebCore/css/typedom/CSSStyleValue.h b/Source/WebCore/css/typedom/CSSStyleValue.h
index da615424d5c4..72f580a5facf 100644
--- a/Source/WebCore/css/typedom/CSSStyleValue.h
+++ b/Source/WebCore/css/typedom/CSSStyleValue.h
@@ -110,7 +110,10 @@ class CSSStyleValue : public RefCounted&lt;CSSStyleValue&gt;, public ScriptWrappable {
 public:
     String toString() const;
     virtual void serialize(StringBuilder&amp;, OptionSet&lt;SerializationArguments&gt; = { }) const;
-    virtual ~CSSStyleValue() = default;
+    virtual ~CSSStyleValue()
+    {
+        m_customPropertyName = { };
+    }
 
     virtual CSSStyleValueType getType() const { return CSSStyleValueType::CSSStyleValue; }
 

If anybody knows a logical reason why this should make any difference....</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1875279</commentid>
    <comment_count>2</comment_count>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2022-06-10 11:42:47 -0700</bug_when>
    <thetext>Pull request: https://github.com/WebKit/WebKit/pull/1448</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1876483</commentid>
    <comment_count>3</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2022-06-17 11:23:23 -0700</bug_when>
    <thetext>&lt;rdar://problem/95401608&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1877092</commentid>
    <comment_count>4</comment_count>
    <who name="EWS">ews-feeder</who>
    <bug_when>2022-06-21 15:01:16 -0700</bug_when>
    <thetext>Committed r295692 (251697@main): &lt;https://commits.webkit.org/251697@main&gt;

Reviewed commits have been landed. Closing PR #1448 and removing active labels.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1890188</commentid>
    <comment_count>5</comment_count>
    <who name="Lauro Moura">lmoura</who>
    <bug_when>2022-08-09 20:44:51 -0700</bug_when>
    <thetext>I&apos;m getting these locally and they are happening on the bots too:

https://build.webkit.org/#/builders/41/builds/13326

Maybe related to this upstream gcc &lt;12 issue (closed as wontfix): &quot;False positive in -Wmismatched-new-delete&quot; https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100485

On why it might still be generating the warning:

&gt;  Alas, keeping the diagnostic ignore local by means of `diagnostic push` / `diagnostic pop` makes it not work correctly, presumably since the warning is generated at the call site.  Making it global to everything including the header file seems like a bad idea to me.

About the bug closure as wontfix:

&gt;  That does sound frustrating, sorry.  The #pragma has a limitation that can make it difficult to use in inlining contexts.  I submitted a patch for it for GCC 11 but it got pushed to GCC 12 (see pr98465 comment 32).  Until it&apos;s fixed, the only other solution I can think of is to prevent the member operator delete from inlining using attribute noinline.

I tried moving the ignore guard to the call site at CSSUnitValue.h (where the new call happens), but it didn&apos;t work. Adding noinline to the destructor though seems to have made the warning disappear, but not sure if this would be an acceptable approach for a compiler warning.

In any case, I did not get the warning with gcc-12, as the upstream bug mentions. For the bots, it should be supported once we migrate to the FDO SDK 22.08.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>