<html>
    <head>
      <base href="http://llvm.org/bugs/" />
    </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 --- - testcase causes ICE from the "Global Variable Optimizer" pass"
   href="http://llvm.org/bugs/show_bug.cgi?id=16637">16637</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>testcase causes ICE from the "Global Variable Optimizer" pass
          </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>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>LLVM Codegen
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>su@cs.ucdavis.edu
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>The following testcase causes the current clang trunk and clang 3.3 to give an
ICE on x86_64-pc-linux-gnu at -O1 and above in 64-bit mode.  This is a
regression from 3.2. 

$ clang-trunk -v
clang version 3.4 (trunk 186424)
Target: x86_64-pc-linux-gnu
Thread model: posix
$ clang-trunk -O1 small.c
small.c:16:19: warning: incompatible pointer types initializing 'char *' with
an expression of type 'int *'
      [-Wincompatible-pointer-types]
        char *c[] = { 0, &b.f1, 0, &b.f0, 0 };
                         ^~~~~
small.c:16:29: warning: incompatible pointer types initializing 'char *' with
an expression of type 'int *'
      [-Wincompatible-pointer-types]
        char *c[] = { 0, &b.f1, 0, &b.f0, 0 };
                                   ^~~~~
small.c:14:10: warning: expression result unused [-Wunused-value]
    for (a; a;)
         ^
0  clang           0x0000000001be4bb5 llvm::sys::PrintStackTrace(_IO_FILE*) +
37
1  clang           0x0000000001be5003
2  libpthread.so.0 0x00007f22e9c57cb0
Stack dump:
0.    Program arguments: /usr/local/clang-trunk/bin/clang -cc1 -triple
x86_64-pc-linux-gnu -emit-obj -disable-free -disable-llvm-verifier
-main-file-name small.c -mrelocation-model static -fmath-errno -masm-verbose
-mconstructor-aliases -munwind-tables -target-cpu x86-64 -target-linker-version
2.22 -momit-leaf-frame-pointer -resource-dir
/usr/local/clang-trunk/bin/../lib/clang/3.4 -internal-isystem
/usr/local/include -internal-isystem
/usr/local/clang-trunk/bin/../lib/clang/3.4/include -internal-externc-isystem
/usr/include/x86_64-linux-gnu -internal-externc-isystem /include
-internal-externc-isystem /usr/include -O1 -fdebug-compilation-dir
/home/su/lookat/ice0716 -ferror-limit 19 -fmessage-length 114 -mstackrealign
-fobjc-runtime=gcc -fobjc-default-synthesize-properties
-fdiagnostics-show-option -fcolor-diagnostics -vectorize-loops -o
/tmp/small-b1acf5.o -x c small.c 
1.    <eof> parser at end of file
2.    Per-module optimization passes
3.    Running pass 'Global Variable Optimizer' on module 'small.c'.
clang: error: unable to execute command: Segmentation fault (core dumped)
clang: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 3.4 (trunk 186424)
Target: x86_64-pc-linux-gnu
Thread model: posix
clang: note: diagnostic msg: PLEASE submit a bug report to
<a href="http://llvm.org/bugs/">http://llvm.org/bugs/</a> and include the crash backtrace, preprocessed source, and
associated run script.
clang: note: diagnostic msg: 
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang: note: diagnostic msg: /tmp/small-2cd2ca.c
clang: note: diagnostic msg: /tmp/small-2cd2ca.sh
clang: note: diagnostic msg: 

********************

$ cat small-2cd2ca.c
# 1 "small.c" 1
struct S
{
  int f0;
  int f1;
};

int a;

static struct S b;

int main ()
{
  for (;;)
    for (a; a;)
      {
    char *c[] = { 0, &b.f1, 0, &b.f0, 0 };
      }
}

$ cat small-2cd2ca.sh
/usr/local/clang-trunk/bin/clang -cc1 -triple x86_64-pc-linux-gnu -emit-obj
-disable-free -disable-llvm-verifier -main-file-name small.c -mrelocation-model
static -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables
-target-cpu x86-64 -target-linker-version 2.22 -momit-leaf-frame-pointer -O1
-ferror-limit 19 -fmessage-length 114 -mstackrealign -fobjc-runtime=gcc
-fobjc-default-synthesize-properties -fdiagnostics-show-option
-fcolor-diagnostics -vectorize-loops -x c small-2cd2ca.c</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>