<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/123198>123198</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            False positive in bugprone-string-constructor
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          JVApen
      </td>
    </tr>
</table>

<pre>
    ````
#include <string>

void f(std::string str)
{
          // Find the substring "FAMILY:" (copied from old code so still using C-style Char pointers)
      const char *ptr = str.c_str();
 std::string copy(ptr, 0, str.size()/2);
}
````
On Compiler Explorer: https://compiler-explorer.com/z/1o86onvGG

The result:
````
[<source>:7:19: warning: constructor creating an empty string [bugprone-string-constructor]]
   7 |       std::string copy(ptr, 0, str.size()/2);
      |                   ^
1 warning generated.
````

In this example, the following constructor of std::string should be called:
````
template< class StringViewLike >
basic_string( const StringViewLike& t,
              size_type pos, size_type count,
 const Allocator& alloc = Allocator() );
````

Since we provide a valid pointer and a valid non-0 count, the string isn't empty by default.
As such, the warning should not be given.

</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJykVEGPozgT_TXOpZTI2CGQAweaHkbzaT7tYVYj7Wlk7CJ417GRbZJJ__qVgaS7t0d7WYSIYtdzPb9XVSIEfbKIFcmfSP68EVMcnK_-970e0W46p24VOdDXl9aEcW2lmRQC4U2IXtsT4Z_SDq0vTivoCStDVITXhNdLAIToCTumoOKJ0BoeD2EtYS202iqIA0KYuhVCGGvr_3_5-kc6iDEgrJRu1Kig9-4MziiQTiEEByFqY2AKCdZsQ7wZhGYQHkanbUQfltxLRulsiCDTNmH1GD0Q_pwI7uSPmWaZovlM85_XkG68EVaOKawBmj4JGPQLrjjWsgecFM_p-16_3yw07jxqgx4-_RyN8-gJr2GIcQzzVZMgcg3Z4hqyk-5MWPtCWJu58uDs5fPnRfPfBwSPYTIxoT_kS8byJrjJS0w-8bogvM6OKedVeDvbVy-q-ElG50F6FDFdV1jA8xhvcLckf-qm0-idxe2ytH2DI_lzemedCyBFs1r830Rcy-Rx2tuH5Knusvs94IQWvYiodr_QgdZfLMRBB8Cf4jwaTIlTyfXOGHddmL2K4PoPxMPgJqOgQ5DCGFS_1DvieTQiIuENSCNCgG8z-rvG61f9V-qaRLoTQc_1lvRn5VqV70MJO0AkrHnXMLOi-gV_xNuIMLow6_dYkG6yd8xyZm2MkyL5ww4g0p-54N8sJ83htWo_6PZNW4lwRRi9u2iFIOAijFb39gJh1WPNOrulDxpLTy_y6WAJK-JaUt0NFPZiMjGZVQcIkxzuiLuhq-LWxaT6SV_QpuiNqrg68qPYYJUVvKCc5zTfDNWh2O-zjKoi74uy46Uqj3mZSUr3lHZK9BtdMcpymmWHjGcly3dlz8u8zFXW5-XxWO7JnuJZaLMz5nLeOX_a6BAmrDLGs2O5MaJDE-ZpyZjFK8y7hLE0PH2VQNtuOgWyp0aHGF6PiToarFphwuyajvqCoC38S0NtJm-q93PhpOMwdeswSGevP9vRuz9RRsLamVFIc2KhfKnY3wEAAP__l5PNwg">