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

    <tr>
        <th>Summary</th>
        <td>
            delete on new[] in llvm libc?
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            libc
      </td>
    </tr>

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

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

<pre>
    https://github.com/llvm/llvm-project/blob/5794854213375017f52914afbae09a12b9a33e06/libc/src/__support/File/file.cpp#L366

https://github.com/llvm/llvm-project/blob/5794854213375017f52914afbae09a12b9a33e06/libc/src/__support/File/file.h#L223


Is it a bug? The delete deletes new[] which should not happen. It should use delete[].

I would suggest not to use new/delete in libc because they introduce a dependency on C++ runtime. Just use malloc and free.

Also, i think the definition of FILE struct stdio in llvm libc is suboptimal. It needs 3 pointers for input, 3 pointers for output. Also another 6 for wchar_t.

https://github.com/bminor/glibc/blob/db57da5be27a0887ce5131c071e2240f5c17aae1/libio/bits/types/struct_FILE.h#L54
Glibc is a good example.

The bufsize needs to be increased to 8192 too.

Can someone who writes the code come here and addresses those issues?
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzMVE1zrDYQ_DXay1QoIWBZDhxsv5By6h1zd-ljWJQIiZJG3ji_PiXYrdg5Jbd3GRVCM93qaY1MyV494si6Z9Z9O8lMS4gjRR2TjWhOKpiPcSHaEmuemJiYmK6WlqwqHVYmJufeH8tPWwy_oyYmJuWCYmLq-qG9dK2om6bveN3PnRjqVs5KIh9kLdQgmwb5uRSwSjMxpVji21vK2xZiKTVZh0xMs3VY6W1jovnenM-Mf2P86Yg_CrulcBOi-cztiK8JLIEEla-smeC3BcGgQ3osCTzejg7AbbF6gbSE7Az4QLDIbUNfwSs9dnN6JB451RcsuO2HUr5eMdFegsKeU0DEdEe2HsqtQKGW5Sct-AHWUwwmawQJBjf0Br3-gODhhYlnJp4hZk92xQp-zYn2qqt0LmiQ3sAcEb-QeXIpMPECFmix_o8CAgZn6y3Z4CHMML1-_xkSxawJEhkbdmLufT3Y2QQpq7CRXaXbNfCIJkEDW7CeMCaYQwTrt0wF6F_7IdOWqYLCA6QPtGCE8_7rphcZ36j6j05Sq_Uhlt27F-4mMqrrjewUil7yy6XX2NVNrXlfoxAtnztd91JifZjIhpJpKTEx0ceGZT0u_1aEOCzUtQebXx4KSLiGYAD_lOvmvgpcrKTynOxfeFeGAqjSXR1RJjTl-1IPAiiEL5kv0kMKKwaPcFsC3KItRiwd0sGUsCIsGHHvrDQmYkr7gZAQbEoZE2umkxkbMzSDPOFY97zjQ9129WkZ-aCFqS-95qrtdTcMqm9Eo6WY5w712ZzsKLhoeV0LwRve9pXi6qJmc8bhIjnnLWs5rtK6qtihCvF62lHHvh_688lJhS7tc0uIoyeiTLA47q9d5WtiLXc2UfqnAFlyON5fQPCfnt1n15Vr5ej-_9i7qyKmneLfAQAA__8p87TG">