<html>
    <head>
      <base href="https://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 --- - clang segfaults on undefined variable" href="https://urldefense.proofpoint.com/v2/url?u=https-3A__llvm.org_bugs_show-5Fbug.cgi-3Fid-3D23902&d=AwMBaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=pF93YEPyB-J_PERP4DUZOJDzFVX5ZQ57vQk33wu0vio&m=9L3x4sPmlX_wsOP6dnS-e8Qz7zSNb3WBaDs9sQiSUkw&s=g341pjhb-_gXiC6UOFYW8N6seI-KCPL_pWJAUbyN7tE&e=">23902</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>clang segfaults on undefined variable
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>new-bugs
          </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>new bugs
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>schopf.dan@gmail.com
          </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>Created <span class=""><a href="attachment.cgi?id=14498" name="attach_14498" title="associated run script">attachment 14498</a> <a href="attachment.cgi?id=14498&action=edit" title="associated run script">[details]</a></span>
associated run script

Compiling the following simple C program makes clang segfault:

#include <math.h>
#include <stdio.h>

int main() {
  printf("%g", fabs(a));
  return 0;
}

Declaring a solves the problem.

# clang -v test.c

clang version 3.7.0 (68aba8badebea3aee8c39002ac01fa12d978747e)
(883d498abf4db0e059a1250147e07f4e9c47d9e3)
Target: x86_64-pc-linux-gnu
Thread model: posix
Selected GCC installation: /usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2
 "/usr/bin/x86_64-pc-linux-gnu-clang-3.7" -cc1 -triple x86_64-pc-linux-gnu
-emit-obj -mrelax-all -disable-free -disable-llvm-verifier -main-file-name
test.c -mrelocation-model static -mthread-model posix -mdisable-fp-elim
-fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables
-fuse-init-array -target-cpu x86-64 -v -dwarf-column-info -resource-dir
/usr/bin/../lib/clang/3.7.0 -internal-isystem /usr/local/include
-internal-isystem /usr/bin/../lib/clang/3.7.0/include -internal-externc-isystem
/include -internal-externc-isystem /usr/include -fdebug-compilation-dir
/home/daniel/workspace -ferror-limit 19 -fmessage-length 191 -mstackrealign
-fobjc-runtime=gcc -fdiagnostics-show-option -fcolor-diagnostics -o
/tmp/test-d1dd8d.o -x c test.c
clang -cc1 version 3.7.0 based upon LLVM 3.7.0svn default target
x86_64-pc-linux-gnu
ignoring nonexistent directory "/usr/local/include"
ignoring nonexistent directory "/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/bin/../lib/clang/3.7.0/include
 /usr/include
End of search list.
x86_64-pc-linux-gnu-clang-3.7: error: unable to execute command: Segmentation
fault
x86_64-pc-linux-gnu-clang-3.7: error: clang frontend command failed due to
signal (use -v to see invocation)
clang version 3.7.0 (68aba8badebea3aee8c39002ac01fa12d978747e)
(883d498abf4db0e059a1250147e07f4e9c47d9e3)
Target: x86_64-pc-linux-gnu
Thread model: posix
x86_64-pc-linux-gnu-clang-3.7: note: diagnostic msg: PLEASE submit a bug report
to <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_bugs_&d=AwMBaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=pF93YEPyB-J_PERP4DUZOJDzFVX5ZQ57vQk33wu0vio&m=9L3x4sPmlX_wsOP6dnS-e8Qz7zSNb3WBaDs9sQiSUkw&s=W4hlg2s84XqV9dgvKseACu94QQvcqPl4ZjXg_PO33RE&e=">http://llvm.org/bugs/</a> and include the crash backtrace, preprocessed source,
and associated run script.
x86_64-pc-linux-gnu-clang-3.7: note: diagnostic msg: 
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
x86_64-pc-linux-gnu-clang-3.7: note: diagnostic msg: /tmp/test-252330.c
x86_64-pc-linux-gnu-clang-3.7: note: diagnostic msg: /tmp/test-252330.sh
x86_64-pc-linux-gnu-clang-3.7: note: diagnostic msg: 

********************</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>