<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 uses >8GB of RAM to build a PCH for a simple header"
   href="https://bugs.llvm.org/show_bug.cgi?id=41625">41625</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Clang uses >8GB of RAM to build a PCH for a simple header
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>8.0
          </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>C++
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>poletti.marco@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>blitzrakete@gmail.com, dgregor@apple.com, erik.pilkington@gmail.com, llvm-bugs@lists.llvm.org, richard-llvm@metafoo.co.uk
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Compiling a PCH for the following code:

struct Wrapper {
   struct X {};
   using Y = X(X(X(X(X(X(X(X(X(X(X(X(X(X(X(X())))))))))))))));
};

With a command like:

clang-8 -x c++-header file.h -o file.pch

Uses several GBs of RAM (>8).

If you want to reproduce, you might want to set a RAM limit in the current
shell, e.g. with "ulimit -Sv 8000000" otherwise your PC might start swapping
and/or become unresponsive.

I tested the following versions of Clang (on Ubuntu Linux):

8.0.0: affected
7.0.1: affected
6.0.1: NOT affected

So this seems to be a regression in Clang 7.x.

The above example is a minimized version of real code in
<a href="https://github.com/google/fruit">https://github.com/google/fruit</a>, where building PCHs now fails in Travis CI
with OOM errors.</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>