<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=http://email.email.llvm.org/c/eJzFVMFu4zYQ_Rr6MqihpezYOuiQTZo2KIou0D3txaDEkcUuRboiaTf79X2UlMTZYg_FHhZgHIqcefM475GN1091a5U7kgmUnGosU_Q08uDPmPVMAw-BIxlHrddM1nxmEsW9KG6X35tiHu3pNK-EqEV5i3HmNvpRlHfGRVH-TJ33Qu6FrEjs3s-xRCpN9UKykUR5T9_KRuafn5ArypdUbJCQt6c4TpkzyFqrqOYyV6GdR4zcv4AH84UPkdyUWCBwmt4RSmAu5HsM94apKCoM1BJb7GzvF7IqmvbQqhCviWawN-XF7v55OnJMo1vIvoTkgOdGzit9jKeQycoHjGPbro9eNx4H9OMRK1_w91vTb37_sG9-mVM-9hBx1rHr0D3WZLpJxLOyifNWllKn0UBwMEAT1kQfexVpUE_PKkBq46xxOch31yZoErI9B3I-ElszGKcicOP62hG_-gufeZx6Pnkm5gIpIA_2CgG0Bo6912F20wIeUhP478Qu2qcfbq2X0JkcIv7rLnlH2_yT2-g7LGa0zEDe0td431b97Un_h_ZdqP7Zf-DquvWPUC9Mkk5ag3u-zc18k6EAjMpZ01n7g3L6gHs-XkaTZXTUJdBknD47BDiPIWdiRdEFBgEWRB2SzapnyFleD1Pgc6r8x5hbAmB6zEvuM1IbjhF-AELeM6-YTTI2ouxklGT1stEslrEcw1JmOBkLCBVCGpbdxZd-fKKLsTZnXVuI8qEiO9AT5QMRr3EgdPhwaFIuepixDrO6dPZGT8ppxl1eVMULAV7TK1MhlTLQStelrspKrWCv3o91w6rtWa_SaOuvhDOxT80a7PFh7fn530-n0f8FC-LTgAQHTLblZleu-rpqdzea27Jtd3ve7lqWvN9KfbMtm2JfFXJlVcM21HiFhJSOLzRBYI43afX9DEwtCymLd3Ivy6IqNuvdht91za7rcGhWvBObggdl7DrjZD-uxnqCbNIxYNOaEMPrJrpsjo55IgyG0UTL9QMAsm9e3xDNSgdcSqZu9APNN3Tx6WriWE8E_wWH0RkP>53473</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            Fail to eliminate deadstore from vector resize
        </td>
    </tr>

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

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

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

<pre>
    clang is unable to remove the memset in code like 

```cpp
std::vector<int> foo() {
  auto result = std::vector<int>(SZ);
  int *ptr = result.data();
  for (std::size_t n = 0; n < SZ; ++n) {
                ptr[n] = static_cast<int>( n );
  }
  return result;
}```
https://gcc.godbolt.org/z/Kbh4MP8bG
This is unaffected if the value is set during resize.  That may result in inlining of the memset but does not eliminate it.

However for code that uses blessed methods like memset subsequently
```cpp
std::vector<int> foo() {
  auto result = std::vector<int>(SZ);
  std::memset(result.data(), 5, sizeof(int) * SZ);
  return result;
}
```
https://gcc.godbolt.org/z/Kfs9x8Pe9

It is.  This seems to be the usecase of resize_and_overwrite in future string.  Is there a way to formulate the code to do this.  Or, and I think a better way, is there a builtin or could there be that lets the compiler assume that the memory will be subsequently written to?  e.g. `__bultin_assume_set( void * dest, size_t count )` ? 
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzFVMFu4zYQ_Rr6MqihSHZsHXTIJpttUBRdoHvqxSDFkcUuRboiaTf79X2UlMTZYg89FaBlipx58zjvUcrr56a10h3JBEpOKssUPY08-DNmPdPAQ-BIxlHrNZM1X5lE8SCKu-V5W8yjPZ3mlRC1qO4wztxGP4rq3rgoqo_UeS_KvShrErsPcyyRTFO9kGwkUT3Qj7KR-fsfyBXVayo2SJR3pzhOmTPIWsso5zJXoZ1HTLl_BQ_mGx8iuSmxQOA0vSeUwFyUHzDcO6aiqDFQS2yxs31YyMpo2kMrQ7wmmsHelRe7h5fpyDGNbiH7GpIDXho5r_QxnkImWz5iHNt2ffRaeRzQj0esfMPvF9Vvfv28V5_mlC89RJx17Dp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