<?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>161365</bug_id>
          
          <creation_ts>2016-08-29 17:22:52 -0700</creation_ts>
          <short_desc>bitwise_cast infinite loops if called from the default constructor in ToType</short_desc>
          <delta_ts>2016-09-02 12:41:17 -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>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <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="Saam Barati">saam</reporter>
          <assigned_to name="JF Bastien">jfbastien</assigned_to>
          <cc>benjamin</cc>
    
    <cc>cdumez</cc>
    
    <cc>cmarcelo</cc>
    
    <cc>commit-queue</cc>
    
    <cc>dbates</cc>
    
    <cc>saam</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1224458</commentid>
    <comment_count>0</comment_count>
    <who name="Saam Barati">saam</who>
    <bug_when>2016-08-29 17:22:52 -0700</bug_when>
    <thetext>...</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1224463</commentid>
    <comment_count>1</comment_count>
    <who name="JF Bastien">jfbastien</who>
    <bug_when>2016-08-29 17:27:04 -0700</bug_when>
    <thetext>This is a mild regression from the previous code which didn&apos;t call either type&apos;s ctor. There&apos;s now kind-of an assumption that ToType is default-constructible, and that its default ctor behaves (almost as if it&apos;s POD). That&apos;s not great. I&apos;ll think of a clever C++-ism to fix. Funny that this is the first time someone runs into this issue just after my change ;-)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1224474</commentid>
    <comment_count>2</comment_count>
    <who name="JF Bastien">jfbastien</who>
    <bug_when>2016-08-29 17:49:38 -0700</bug_when>
    <thetext>I take back what I said: it wasn&apos;t possible before to use bitwise_cast when ToType had a non-trivial ctor (in that case the default ctor of the union is deleted), but could have been made so with a noop ctor in the union:

template&lt;typename To, typename From&gt;
To bit_cast(From from) {
	union U { U() {}; To to; From from; } u;
  u.from = from;
  return u.to;
}

struct A {
  A(int in = 5) { v = in; }
  operator int() { return v; }
  int v;
};

int main() {
  return bit_cast&lt;A&gt;(3.14);
}

This is horrible and should not be done.

The standard says: If any non-static data member of a union has a non-trivial default constructor (12.1), copy constructor (12.8), move constructor (12.8), copy assignment operator (12.8), move assignment operator (12.8), or destructor (12.4), the corresponding member function of the union must be user-provided or it will be implicitly deleted (8.4.3) for the union.


This is therefore a regression in that the new version of bitwise_cast is *more* permissive because it accepts ToTypes which aren&apos;t trivially constructible, but will cause sad recursion when the ToType calls bitwise_cast.

Let&apos;s think about this some more...</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1225444</commentid>
    <comment_count>3</comment_count>
      <attachid>287651</attachid>
    <who name="JF Bastien">jfbastien</who>
    <bug_when>2016-09-01 12:00:37 -0700</bug_when>
    <thetext>Created attachment 287651
patch

This patch fixes the one issue.

I&apos;m still not happy about From being copied in (it should be an rvalue ref, or at least a const ref), but the build disagrees with me.

I&apos;m working on adding this to the C++ standard library so we&apos;d have this fixed once and for all. I still need to add concepts (instead of static_assert or SFINAE) and make constexpr work (ugh!) but I have some proposed wording and a bunch of tests.

I think fixing this minor issue is good enough for now, and C++20 will have the most wonderful fix.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1225446</commentid>
    <comment_count>4</comment_count>
    <who name="WebKit Commit Bot">commit-queue</who>
    <bug_when>2016-09-01 12:02:45 -0700</bug_when>
    <thetext>Attachment 287651 did not pass style-queue:


ERROR: Source/WTF/wtf/StdLibExtras.h:154:  Missing space before {  [whitespace/braces] [5]
ERROR: Source/WTF/wtf/StdLibExtras.h:154:  Missing space inside { }.  [whitespace/braces] [5]
Total errors found: 2 in 2 files


If any of these errors are false positives, please file a bug against check-webkit-style.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1225603</commentid>
    <comment_count>5</comment_count>
      <attachid>287651</attachid>
    <who name="Saam Barati">saam</who>
    <bug_when>2016-09-01 16:18:39 -0700</bug_when>
    <thetext>Comment on attachment 287651
patch

View in context: https://bugs.webkit.org/attachment.cgi?id=287651&amp;action=review

r=me

&gt; Source/WTF/wtf/StdLibExtras.h:154
&gt; +    ToType to{};

Nit: I think webkit style is to have &quot;{ }&quot; instead of &quot;{}&quot;. It&apos;s worth verifying.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1225872</commentid>
    <comment_count>6</comment_count>
      <attachid>287794</attachid>
    <who name="JF Bastien">jfbastien</who>
    <bug_when>2016-09-02 12:09:45 -0700</bug_when>
    <thetext>Created attachment 287794
patch

Fix style.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1225875</commentid>
    <comment_count>7</comment_count>
    <who name="WebKit Commit Bot">commit-queue</who>
    <bug_when>2016-09-02 12:11:39 -0700</bug_when>
    <thetext>Attachment 287794 did not pass style-queue:


ERROR: Source/WTF/wtf/StdLibExtras.h:154:  Missing space before {  [whitespace/braces] [5]
Total errors found: 1 in 2 files


If any of these errors are false positives, please file a bug against check-webkit-style.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1225894</commentid>
    <comment_count>8</comment_count>
      <attachid>287794</attachid>
    <who name="WebKit Commit Bot">commit-queue</who>
    <bug_when>2016-09-02 12:40:56 -0700</bug_when>
    <thetext>Comment on attachment 287794
patch

Clearing flags on attachment: 287794

Committed r205362: &lt;http://trac.webkit.org/changeset/205362&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1225895</commentid>
    <comment_count>9</comment_count>
    <who name="WebKit Commit Bot">commit-queue</who>
    <bug_when>2016-09-02 12:41:17 -0700</bug_when>
    <thetext>All reviewed patches have been landed.  Closing bug.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="1"
              ispatch="1"
              isprivate="0"
          >
            <attachid>287651</attachid>
            <date>2016-09-01 12:00:37 -0700</date>
            <delta_ts>2016-09-02 12:09:45 -0700</delta_ts>
            <desc>patch</desc>
            <filename>0001-aggregate-init.patch</filename>
            <type>text/plain</type>
            <size>1522</size>
            <attacher name="JF Bastien">jfbastien</attacher>
            
              <data encoding="base64">RnJvbSA4NTFkNmE2OTgwM2Q1YTU0NjM0YmJjZTI1Nzc5NTFjNjZlY2M0YjU4IE1vbiBTZXAgMTcg
MDA6MDA6MDAgMjAwMQpGcm9tOiBKRiBCYXN0aWVuIDxqZmJhc3RpZW5AYXBwbGUuY29tPgpEYXRl
OiBUaHUsIDEgU2VwIDIwMTYgMTE6NTU6MjUgLTA3MDAKU3ViamVjdDogW1BBVENIXSBhZ2dyZWdh
dGUgaW5pdAoKLS0tCiBTb3VyY2UvV1RGL0NoYW5nZUxvZyAgICAgICAgICB8IDEwICsrKysrKysr
KysKIFNvdXJjZS9XVEYvd3RmL1N0ZExpYkV4dHJhcy5oIHwgIDIgKy0KIDIgZmlsZXMgY2hhbmdl
ZCwgMTEgaW5zZXJ0aW9ucygrKSwgMSBkZWxldGlvbigtKQoKZGlmZiAtLWdpdCBhL1NvdXJjZS9X
VEYvQ2hhbmdlTG9nIGIvU291cmNlL1dURi9DaGFuZ2VMb2cKaW5kZXggYjkxMzAwMi4uNDI1ZGZh
YyAxMDA2NDQKLS0tIGEvU291cmNlL1dURi9DaGFuZ2VMb2cKKysrIGIvU291cmNlL1dURi9DaGFu
Z2VMb2cKQEAgLTEsMyArMSwxMyBAQAorMjAxNi0wOS0wMSAgSkYgQmFzd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lwZSEiKTsKICAgICBz
dGF0aWNfYXNzZXJ0KF9faXNfdHJpdmlhbGx5X2NvcHlhYmxlKEZyb21UeXBlKSwgImJpdHdpc2Vf
Y2FzdCBvZiBub24tdHJpdmlhbGx5LWNvcHlhYmxlIHR5cGUhIik7CiAjZW5kaWYKLSAgICBUb1R5
cGUgdG87CisgICAgVG9UeXBlIHRve307CiAgICAgc3RkOjptZW1jcHkoJnRvLCAmZnJvbSwgc2l6
ZW9mKHRvKSk7CiAgICAgcmV0dXJuIHRvOwogfQotLSAKMi45LjMKCg==
</data>
<flag name="review"
          id="311092"
          type_id="1"
          status="+"
          setter="saam"
    />
    <flag name="commit-queue"
          id="311093"
          type_id="3"
          status="-"
          setter="saam"
    />
          </attachment>
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>287794</attachid>
            <date>2016-09-02 12:09:45 -0700</date>
            <delta_ts>2016-09-02 12:40:56 -0700</delta_ts>
            <desc>patch</desc>
            <filename>0001-aggregate-init.patch</filename>
            <type>text/plain</type>
            <size>1517</size>
            <attacher name="JF Bastien">jfbastien</attacher>
            
              <data encoding="base64">RnJvbSA5NzdiYTYxZWJjYmE3NTJiNDdkZTVkOWFiZjBlNDhmNTNhYWU0ZTZhIE1vbiBTZXAgMTcg
MDA6MDA6MDAgMjAwMQpGcm9tOiBKRiBCYXN0aWVuIDxqZmJhc3RpZW5AYXBwbGUuY29tPgpEYXRl
OiBUaHUsIDEgU2VwIDIwMTYgMTE6NTU6MjUgLTA3MDAKU3ViamVjdDogW1BBVENIXSBhZ2dyZWdh
dGUgaW5pdAoKLS0tCiBTb3VyY2UvV1RGL0NoYW5nZUxvZyAgICAgICAgICB8IDEwICsrKysrKysr
KysKIFNvdXJjZS9XVEYvd3RmL1N0ZExpYkV4dHJhcy5oIHwgIDIgKy0KIDIgZmlsZXMgY2hhbmdl
ZCwgMTEgaW5zZXJ0aW9ucygrKSwgMSBkZWxldGlvbigtKQoKZGlmZiAtLWdpdCBh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