<html>
    <head>
      <base href="https://bugs.documentfoundation.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_UNCONFIRMED "
   title="UNCONFIRMED - Don't use static_cast with numeric literals"
   href="https://bugs.documentfoundation.org/show_bug.cgi?id=131117">131117</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Don't use static_cast with numeric literals
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>LibreOffice
          </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>UNCONFIRMED
          </td>
        </tr>

        <tr>
          <th>Keywords</th>
          <td>difficultyBeginner, easyHack, skillCpp, topicCleanup
          </td>
        </tr>

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

        <tr>
          <th>Priority</th>
          <td>medium
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>LibreOffice
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>libreoffice-bugs@lists.freedesktop.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>mikekaganski@hotmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>sbergman@redhat.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Throughout the codebase, there are places where a numeric literal is used to
create a value of a specified type, using `static_cast<wanted_type>(literal)`
syntax.

I suppose this is not a correct semantically, since static_cast is to cast some
existing value of a different type into wanted other type; while when literals
are involved, what happens is *creation* of a new value of specified type. In
my opinion, it's better to use function-style (ctor-style) cast syntax here,
like `wanted_type(literal)`.

To see the examples of this (like `static_cast< sal_Int64 >(1)` in [1], which
should become simply `sal_Int64(1)` in this task), grep for

    static_cast\s*<[^>]+>\s*\(\s*-?\d+\.?\d*\s*\)

which gives around 2000 matches currently.

[1] <a href="https://opengrok.libreoffice.org/xref/core/sal/rtl/math.cxx?r=1782810f#285">https://opengrok.libreoffice.org/xref/core/sal/rtl/math.cxx?r=1782810f#285</a></pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are the assignee for the bug.</li>
      </ul>
    </body>
</html>