<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </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 - "clang -c -emit-llvm" deletes input file if the file has invalid format and .bc suffix"
   href="https://bugs.llvm.org/show_bug.cgi?id=40298">40298</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>"clang -c -emit-llvm" deletes input file if the file has invalid format and .bc suffix
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </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>Driver
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>wangxiayang.fdt@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org, neeilans@live.com, richard-llvm@metafoo.co.uk
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Hi. I found clang deleted my input file as 'Repro' suggested. Partly it was my
mistake by making the input and output files have the same name. But maybe
clang could warn me or abort such compiling action in order not to corrupt my
input file.

Repro:
1. A trivial C program like: void foo() {}
2. Save as test.c
3. $ clang -c -emit-llvm test.c
4. $ llvm-ar rcu test.a.bc test.bc
5. $ clang -c -emit-llvm test.a.bc

Result:
test.a.bc is deleted by clang after 5.

Notes and comments:
1) Step 4 is simply a way to create an invalid LLVM bitcode file with .bc
suffix.
2) Tested with svn repo. "svn info" shows "Last Changed Rev: 351002" and
"Revision: 351007"
3) gcc sometimes reports like 'input and output file have the same name'. So I
wonder whether clang would prefer to warn or abort instead of removing the
input file.

Thank you!</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>