<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 --- - clang crashes on valid code at -O1 and above in 32-bit mode (affecting all clang versions)"
   href="http://llvm.org/bugs/show_bug.cgi?id=17936">17936</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>clang crashes on valid code at -O1 and above in 32-bit mode (affecting all clang versions)
          </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>-New Bugs
          </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 current clang trunk and older versions crash when compiling the following
testcase at -O1 and above in 32-bit mode (but not 64-bit mode) on
x86_64-pc-linux-gnu. 

It also appears to affect MacOS X. 

$ clang-trunk -v
clang version 3.4 (trunk 194743)
Target: x86_64-unknown-linux-gnu
Thread model: posix
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.4
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.4.6
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.4.7
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.6
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.6.3
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.6

$ clang-trunk -m32 -O0 -c small.c
$ clang-trunk -m64 -O1 -c small.c

$ clang-trunk -m32 -O1 -c small.c
Call result #3 has unhandled type i32
UNREACHABLE executed at /tmp/llvm/lib/CodeGen/CallingConvLower.cpp:165!
0  clang           0x00000000025dede2 llvm::sys::PrintStackTrace(_IO_FILE*) +
34
1  clang           0x00000000025de1c9
2  libpthread.so.0 0x00007f12c1655cb0
3  libc.so.6       0x00007f12c067f425 gsignal + 53
4  libc.so.6       0x00007f12c0682b8b abort + 379
5  clang           0x00000000025c9a1c
6  clang           0x0000000001f3bfa6
llvm::CCState::AnalyzeCallResult(llvm::SmallVectorImpl<llvm::ISD::InputArg>
const&, bool (*)(unsigned int, llvm::MVT, llvm::MVT,
llvm::CCValAssign::LocInfo, llvm::ISD::ArgFlagsTy, llvm::CCState&)) + 374
7  clang           0x0000000001c651ce
llvm::X86TargetLowering::LowerCallResult(llvm::SDValue, llvm::SDValue,
llvm::CallingConv::ID, bool, llvm::SmallVectorImpl<llvm::ISD::InputArg> const&,
llvm::SDLoc, llvm::SelectionDAG&, llvm::SmallVectorImpl<llvm::SDValue>&) const
+ 254
8  clang           0x0000000001c88569
llvm::X86TargetLowering::LowerCall(llvm::TargetLowering::CallLoweringInfo&,
llvm::SmallVectorImpl<llvm::SDValue>&) const + 8089
9  clang           0x0000000001da4dc5
llvm::TargetLowering::LowerCallTo(llvm::TargetLowering::CallLoweringInfo&)
const + 3157
10 clang           0x0000000001df817c
llvm::TargetLowering::makeLibCall(llvm::SelectionDAG&, llvm::RTLIB::Libcall,
llvm::EVT, llvm::SDValue const*, unsigned int, bool, llvm::SDLoc, bool, bool)
const + 1180
11 clang           0x0000000001ea5ac1
12 clang           0x0000000001eb7e4b
13 clang           0x0000000001e3c211
14 clang           0x0000000001e3ce93 llvm::SelectionDAG::LegalizeTypes() + 355
15 clang           0x0000000001de3e6c
llvm::SelectionDAGISel::CodeGenAndEmitDAG() + 636
16 clang           0x0000000001ded3b1
llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) + 1777
17 clang           0x0000000001deeed8
llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) + 1416
18 clang           0x00000000025673af
llvm::FPPassManager::runOnFunction(llvm::Function&) + 607
19 clang           0x000000000256741b
llvm::FPPassManager::runOnModule(llvm::Module&) + 43
20 clang           0x0000000002566f6f
llvm::legacy::PassManagerImpl::run(llvm::Module&) + 927
21 clang           0x0000000000917fb2
clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::CodeGenOptions
const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::Module*,
clang::BackendAction, llvm::raw_ostream*) + 3666
22 clang           0x000000000091537d
23 clang           0x0000000000ac0e44 clang::ParseAST(clang::Sema&, bool, bool)
+ 372
24 clang           0x00000000007868da clang::FrontendAction::Execute() + 282
25 clang           0x0000000000768bf0
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 352
26 clang           0x000000000074e65d
clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 1693
27 clang           0x00000000007478f0 cc1_main(char const**, char const**, char
const*, void*) + 1232
28 clang           0x000000000072b029 main + 665
29 libc.so.6       0x00007f12c066a76d __libc_start_main + 237
30 clang           0x00000000007472b1
Stack dump:
0.    Program arguments: /usr/local/clang-trunk/bin/clang -cc1 -triple
i386-unknown-linux-gnu -emit-obj -disable-free -main-file-name small.c
-mrelocation-model static -fmath-errno -masm-verbose -mconstructor-aliases
-target-cpu pentium4 -target-linker-version 2.22 -momit-leaf-frame-pointer
-coverage-file /home/su/crashes/crash1/small.o -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
/include -internal-externc-isystem /usr/include -O1 -fdebug-compilation-dir
/home/su/crashes/crash1 -ferror-limit 19 -fmessage-length 96 -mstackrealign
-fobjc-runtime=gcc -fdiagnostics-show-option -fcolor-diagnostics -vectorize-slp
-o small.o -x c small.c 
1.    <eof> parser at end of file
2.    Code generation
3.    Running pass 'Function Pass Manager' on module 'small.c'.
4.    Running pass 'X86 DAG->DAG Instruction Selection' on function '@foo'
clang: error: unable to execute command: Aborted (core dumped)
clang: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 3.4 (trunk 194743)
Target: i386-unknown-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-30d496.c
clang: note: diagnostic msg: /tmp/small-30d496.sh
clang: note: diagnostic msg: 

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



-------------------------


int a;
long long b, c;

void foo ()
{
  for (; c; c++)
    b -= a++;
}</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>