<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 runs OOM when checking for constant initialization of array"
   href="https://bugs.llvm.org/show_bug.cgi?id=51712">51712</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Clang runs OOM when checking for constant initialization of array
          </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>All
          </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>Frontend
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>kadircetinkaya.06.tr@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>```
cat > a.cc <<EOF
struct {
  int a, b, c, d;
} arr[50][6000000];
EOF
clang -fsyntax-only -xc++ a.cc
```

Results in clang consuming huge memory (tried with ~190GiB) and OOMing in the
end. A sample backtrace looks like:
```
#0  getDefaultInitValue () at
/usr/local/google/home/kadircet/repos/llvm/clang/lib/AST/ExprConstant.cpp:4733
#1  0x0000000004e75412 in getDefaultInitValue () at
/usr/local/google/home/kadircet/repos/llvm/clang/lib/AST/ExprConstant.cpp:4726
#2  0x0000000004ed80ae in VisitCXXConstructExpr () at
/usr/local/google/home/kadircet/repos/llvm/clang/lib/AST/ExprConstant.cpp:10484
#3  0x0000000004ed8283 in VisitCXXConstructExpr () at
/usr/local/google/home/kadircet/repos/llvm/clang/lib/AST/ExprConstant.cpp:10471
#4  0x0000000004ed8283 in VisitCXXConstructExpr () at
/usr/local/google/home/kadircet/repos/llvm/clang/lib/AST/ExprConstant.cpp:10471
#5  0x0000000004e7259b in EvaluateArray () at
/usr/local/google/home/kadircet/repos/llvm/clang/lib/AST/ExprConstant.cpp:10298
#6  EvaluateInPlace () at
/usr/local/google/home/kadircet/repos/llvm/clang/lib/AST/ExprConstant.cpp:14463
#7  0x0000000004e74596 in EvaluateAsInitializer () at
/usr/local/google/home/kadircet/repos/llvm/clang/lib/AST/ExprConstant.cpp:14725
#8  0x0000000004ddf0ef in evaluateValueImpl () at
/usr/local/google/home/kadircet/repos/llvm/clang/lib/AST/Decl.cpp:2389
#9  0x0000000004ddf287 in checkForConstantInitialization () at
/usr/local/google/home/kadircet/repos/llvm/clang/lib/AST/Decl.cpp:2460
#10 0x0000000004507705 in CheckCompleteVariableDeclaration () at
/usr/local/google/home/kadircet/repos/llvm/clang/lib/Sema/SemaDecl.cpp:13007
#11 0x00000000044ea30b in ActOnUninitializedDecl () at
/usr/local/google/home/kadircet/repos/llvm/clang/lib/Sema/SemaDecl.cpp:12704
#12 0x00000000042ec53d in ParseDeclarationAfterDeclaratorAndAttributes () at
/usr/local/google/home/kadircet/repos/llvm/clang/lib/Parse/ParseDecl.cpp:2387
#13 0x00000000042eaa9d in ParseDeclGroup () at
/usr/local/google/home/kadircet/repos/llvm/clang/lib/Parse/ParseDecl.cpp:2038
#14 0x00000000042caa9c in ParseDeclOrFunctionDefInternal () at
/usr/local/google/home/kadircet/repos/llvm/clang/lib/Parse/Parser.cpp:1135
#15 0x00000000042ca4e5 in ParseDeclarationOrFunctionDefinition () at
/usr/local/google/home/kadircet/repos/llvm/clang/lib/Parse/Parser.cpp:1151
#16 0x00000000042c91ee in ParseExternalDeclaration () at
/usr/local/google/home/kadircet/repos/llvm/clang/lib/Parse/Parser.cpp:971
#17 0x00000000042c6e34 in ParseTopLevelDecl () at
/usr/local/google/home/kadircet/repos/llvm/clang/lib/Parse/Parser.cpp:716
#18 0x00000000042c65b7 in ParseFirstTopLevelDecl () at
/usr/local/google/home/kadircet/repos/llvm/clang/lib/Parse/Parser.cpp:588
#19 0x00000000042c1321 in ParseAST () at
/usr/local/google/home/kadircet/repos/llvm/clang/lib/Parse/ParseAST.cpp:157
#20 0x000000000312399d in Execute () at
/usr/local/google/home/kadircet/repos/llvm/clang/lib/Frontend/FrontendAction.cpp:949
#21 0x00000000030b35e2 in ExecuteAction () at
/usr/local/google/home/kadircet/repos/llvm/clang/lib/Frontend/CompilerInstance.cpp:989
#22 0x00000000031d6a62 in ExecuteCompilerInvocation () at
/usr/local/google/home/kadircet/repos/llvm/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:278
#23 0x00000000009e8703 in cc1_main () at
/usr/local/google/home/kadircet/repos/llvm/clang/tools/driver/cc1_main.cpp:240
#24 0x00000000009e66fc in ExecuteCC1Tool () at
/usr/local/google/home/kadircet/repos/llvm/clang/tools/driver/driver.cpp:330
#25 0x0000000002f5cb32 in operator() () at
/usr/local/google/home/kadircet/repos/llvm/clang/lib/Driver/Job.cpp:404
#26 callback_fn<(lambda at
/usr/local/google/home/kadircet/repos/llvm/clang/lib/Driver/Job.cpp:404:22)>(void)
() at
/usr/local/google/home/kadircet/repos/llvm/llvm/include/llvm/ADT/STLExtras.h:185
#27 0x0000000002870041 in operator() () at
/usr/local/google/home/kadircet/repos/llvm/llvm/include/llvm/ADT/STLExtras.h:209
#28 RunSafely () at
/usr/local/google/home/kadircet/repos/llvm/llvm/lib/Support/CrashRecoveryContext.cpp:424
#29 0x0000000002f5c1f7 in Execute () at
/usr/local/google/home/kadircet/repos/llvm/clang/lib/Driver/Job.cpp:404
#30 0x0000000002f272c8 in ExecuteCommand () at
/usr/local/google/home/kadircet/repos/llvm/clang/lib/Driver/Compilation.cpp:195
#31 0x0000000002f27817 in ExecuteJobs () at
/usr/local/google/home/kadircet/repos/llvm/clang/lib/Driver/Compilation.cpp:246
#32 0x0000000002f41c88 in ExecuteCompilation () at
/usr/local/google/home/kadircet/repos/llvm/clang/lib/Driver/Driver.cpp:1510
#33 0x00000000009e5df4 in main () at
/usr/local/google/home/kadircet/repos/llvm/clang/tools/driver/driver.cpp:502
```

All of the backtrace samples I grabbed had `checkForConstantInitialization` as
LCA.</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>