<html>
    <head>
      <base href="http://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - std::complex::operator*= too restrictive with types it accepts"
   href="http://llvm.org/bugs/show_bug.cgi?id=19189">19189</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>std::complex::operator*= too restrictive with types it accepts
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libc++
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>All Bugs
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>d.grellscheid+llvm@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu, mclow.lists@gmail.com
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Changeset r187529 for <complex> has imposed additional restrictions on the
accepted types in operator*=. An example of the problematic change is below.

Where previously only the existence of

  complex<_Tp> operator*(complex<_Tp>, complex<_Xp>)

was necessary for the implementation of operator*=, 
now a constructor _Tp(_Xp) is required. 

Is this new constraint deliberately there?

An example situation where the new behaviour is problematic is for physical
units types that should never be directly constructed from doubles, but which
can be multiplied by doubles. 



Index: complex
===================================================================
--- complex     (revision 187528)
+++ complex     (revision 187529)
@@ -309,12 +309,12 @@
         }
     template<class _Xp> _LIBCPP_INLINE_VISIBILITY complex& operator*=(const
complex<_Xp>& __c)
         {
-            *this = *this * __c;
+            *this = *this * complex(__c.real(), __c.imag());
             return *this;
         }
     template<class _Xp> _LIBCPP_INLINE_VISIBILITY complex& operator/=(const
complex<_Xp>& __c)
         {
-            *this = *this / __c;
+            *this = *this / complex(__c.real(), __c.imag());
             return *this;
         }
 };</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>