<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 a lot of memory when compiling new T[big number]"
href="https://bugs.llvm.org/show_bug.cgi?id=51077">51077</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>clang uses a lot of memory when compiling new T[big number]
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>11.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>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>-New Bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>mihail.dektyarow@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org, neeilans@live.com, richard-llvm@metafoo.co.uk
</td>
</tr></table>
<p>
<div>
<pre>Created <span class=""><a href="attachment.cgi?id=25020" name="attach_25020" title="clang stdout">attachment 25020</a> <a href="attachment.cgi?id=25020&action=edit" title="clang stdout">[details]</a></span>
clang stdout
Steps to reproduce:
1. Create file source.cpp with following content:
struct T {
char x;
};
T* f() {
return new T[100000000];
}
2. Run clang++ -v -c source.cpp -o source.o
Expected outcome:
clang creates object file without using too much memory
Actual outcome:
clang uses about 8GB of memory (and then on my machine is killed for OOM)
clang output attached.
This is easily reproducible on godbolt.org: clang 9 compiles this code just
fine, clang 10.0 or above reports out of memory <a href="https://godbolt.org/z/d9oej9a57">https://godbolt.org/z/d9oej9a57</a>
If we replace struct T with using T = char, everything works fine.
If we replace T[100000000] with T[10000000], clang uses about 1.6GB of memory
but compiles successfully.
On other machine, clang 12 compiles this file, but uses about 12GB of memory in
process.</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>