<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 crashes on valid code at -Os and above on x86_64-linux-gnu (in 64-bit mode, but not in 32-bit): Assertion `Num < NumOperands && "Invalid child # of SDNode!"' failed"
   href="https://bugs.llvm.org/show_bug.cgi?id=33113">33113</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>clang crashes on valid code at -Os and above on x86_64-linux-gnu (in 64-bit mode, but not in 32-bit): Assertion `Num < NumOperands && "Invalid child # of SDNode!"' failed
          </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>-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>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>$ clang -v
clang version 5.0.0 (trunk 303464)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/clang-trunk/bin
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/5
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/5.4.0
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/6
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/6.0.0
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.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.4
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.7
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.7.4
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8.5
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9.3
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5.4.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6.0.0
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5.4.0
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Candidate multilib: x32;@mx32
Selected multilib: .;@m64

$ clang -O1 -c small.c
$ clang-4.0.0 -Os -c small.c

$ clang -Os -c small.c
clang-5.0:
/tmp/llvm-builder/llvm-source-trunk/include/llvm/CodeGen/SelectionDAGNodes.h:797:
const llvm::SDValue& llvm::SDNode::getOperand(unsigned int) const: Assertion
`Num < NumOperands && "Invalid child # of SDNode!"' failed.
#0 0x000000000221f1aa llvm::sys::PrintStackTrace(llvm::raw_ostream&)
(/usr/local/clang-trunk/bin/clang-5.0+0x221f1aa)
#1 0x000000000221cf2e llvm::sys::RunSignalHandlers()
(/usr/local/clang-trunk/bin/clang-5.0+0x221cf2e)
#2 0x000000000221d0a2 SignalHandler(int)
(/usr/local/clang-trunk/bin/clang-5.0+0x221d0a2)
#3 0x00007f848f3a3390 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x11390)
#4 0x00007f848e116428 gsignal
/build/glibc-9tT8Do/glibc-2.23/signal/../sysdeps/unix/sysv/linux/raise.c:54:0
#5 0x00007f848e11802a abort /build/glibc-9tT8Do/glibc-2.23/stdlib/abort.c:91:0
#6 0x00007f848e10ebd7 __assert_fail_base
/build/glibc-9tT8Do/glibc-2.23/assert/assert.c:92:0
#7 0x00007f848e10ec82 (/lib/x86_64-linux-gnu/libc.so.6+0x2dc82)
#8 0x00000000028c9d03 (/usr/local/clang-trunk/bin/clang-5.0+0x28c9d03)
#9 0x00000000028feeaa (anonymous
namespace)::DAGCombiner::ExtendSetCCUses(llvm::SmallVectorImpl<llvm::SDNode*>
const&, llvm::SDValue, llvm::SDValue, llvm::SDLoc const&, llvm::ISD::NodeType)
[clone .isra.588] (/usr/local/clang-trunk/bin/clang-5.0+0x28feeaa)
#10 0x00000000029067a3 (anonymous
namespace)::DAGCombiner::visitSIGN_EXTEND(llvm::SDNode*)
(/usr/local/clang-trunk/bin/clang-5.0+0x29067a3)
#11 0x0000000002920435 (anonymous namespace)::DAGCombiner::visit(llvm::SDNode*)
(/usr/local/clang-trunk/bin/clang-5.0+0x2920435)
#12 0x00000000029221df (anonymous
namespace)::DAGCombiner::combine(llvm::SDNode*)
(/usr/local/clang-trunk/bin/clang-5.0+0x29221df)
#13 0x00000000029253d2 (anonymous
namespace)::DAGCombiner::Run(llvm::CombineLevel) [clone .constprop.623]
(/usr/local/clang-trunk/bin/clang-5.0+0x29253d2)
#14 0x0000000002927554 llvm::SelectionDAG::Combine(llvm::CombineLevel,
llvm::AAResults*, llvm::CodeGenOpt::Level)
(/usr/local/clang-trunk/bin/clang-5.0+0x2927554)
#15 0x00000000029dede8 llvm::SelectionDAGISel::CodeGenAndEmitDAG()
(/usr/local/clang-trunk/bin/clang-5.0+0x29dede8)
#16 0x00000000029e9c49
llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&)
(/usr/local/clang-trunk/bin/clang-5.0+0x29e9c49)
#17 0x00000000029eb9c7
llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) [clone
.part.774] [clone .constprop.798]
(/usr/local/clang-trunk/bin/clang-5.0+0x29eb9c7)
#18 0x00000000016558c4 (anonymous
namespace)::X86DAGToDAGISel::runOnMachineFunction(llvm::MachineFunction&)
(/usr/local/clang-trunk/bin/clang-5.0+0x16558c4)
#19 0x0000000001a6b1d5
llvm::MachineFunctionPass::runOnFunction(llvm::Function&)
(/usr/local/clang-trunk/bin/clang-5.0+0x1a6b1d5)
#20 0x0000000001d79a33 llvm::FPPassManager::runOnFunction(llvm::Function&)
(/usr/local/clang-trunk/bin/clang-5.0+0x1d79a33)
#21 0x0000000001d79afc llvm::FPPassManager::runOnModule(llvm::Module&)
(/usr/local/clang-trunk/bin/clang-5.0+0x1d79afc)
#22 0x0000000001d7959d llvm::legacy::PassManagerImpl::run(llvm::Module&)
(/usr/local/clang-trunk/bin/clang-5.0+0x1d7959d)
#23 0x00000000023ce3b8 clang::EmitBackendOutput(clang::DiagnosticsEngine&,
clang::HeaderSearchOptions const&, clang::CodeGenOptions const&,
clang::TargetOptions const&, clang::LangOptions const&, llvm::DataLayout
const&, llvm::Module*, clang::BackendAction,
std::unique_ptr<llvm::raw_pwrite_stream,
std::default_delete<llvm::raw_pwrite_stream> >)
(/usr/local/clang-trunk/bin/clang-5.0+0x23ce3b8)
#24 0x0000000002aa80a9
clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&)
(/usr/local/clang-trunk/bin/clang-5.0+0x2aa80a9)
#25 0x0000000002e693f8 clang::ParseAST(clang::Sema&, bool, bool)
(/usr/local/clang-trunk/bin/clang-5.0+0x2e693f8)
#26 0x0000000002aa743f clang::CodeGenAction::ExecuteAction()
(/usr/local/clang-trunk/bin/clang-5.0+0x2aa743f)
#27 0x00000000027680a6 clang::FrontendAction::Execute()
(/usr/local/clang-trunk/bin/clang-5.0+0x27680a6)
#28 0x0000000002739ec6
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/usr/local/clang-trunk/bin/clang-5.0+0x2739ec6)
#29 0x00000000027f3cea
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/usr/local/clang-trunk/bin/clang-5.0+0x27f3cea)
#30 0x0000000000c9b1e8 cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) (/usr/local/clang-trunk/bin/clang-5.0+0xc9b1e8)
#31 0x0000000000c2e4f0 main (/usr/local/clang-trunk/bin/clang-5.0+0xc2e4f0)
#32 0x00007f848e101830 __libc_start_main
/build/glibc-9tT8Do/glibc-2.23/csu/../csu/libc-start.c:325:0
#33 0x0000000000c978a9 _start (/usr/local/clang-trunk/bin/clang-5.0+0xc978a9)
Stack dump:
0.      Program arguments: /usr/local/clang-trunk/bin/clang-5.0 -cc1 -triple
x86_64-unknown-linux-gnu -emit-obj -disable-free -main-file-name small.c
-mrelocation-model static -mthread-model posix -fmath-errno -masm-verbose
-mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64
-momit-leaf-frame-pointer -dwarf-column-info -debugger-tuning=gdb
-coverage-notes-file /home/su/small.gcno -resource-dir
/usr/local/clang-trunk/lib/clang/5.0.0 -internal-isystem /usr/local/include
-internal-isystem /usr/local/clang-trunk/lib/clang/5.0.0/include
-internal-externc-isystem /usr/include/x86_64-linux-gnu
-internal-externc-isystem /include -internal-externc-isystem /usr/include -Os
-fdebug-compilation-dir /home/su -ferror-limit 19 -fmessage-length 120
-fobjc-runtime=gcc -fdiagnostics-show-option -fcolor-diagnostics
-vectorize-loops -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 '@fn1'
clang-5.0: error: unable to execute command: Aborted (core dumped)
clang-5.0: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 5.0.0 (trunk 303464)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/clang-trunk/bin
clang-5.0: 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-5.0: note: diagnostic msg: 
********************

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

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



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


short a, d, h;
int b, c, f;
long e, g;

void fn1 ()
{
  short j = f, k = e * g, m = ~a;
  int l = (a ^ (j & ((f && c) - e))) | -d * ~b;
  h = ~g | ((k < g - a) ^ -j) | ((f - !(~e & (a > l << (g - (k ^ b))) && j)) ^
h);
  long n = (~g - h) & 4073709551608
    || c, o = g * 4073709551608 ^ h << -m ^ n * d;
  short p = e = (n * f - m) ^ (g | (-h & o) || b);
  g = p / o | ~f;
  d = f || d;
}</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>