<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 crashes on valid code at -Os and -O2 (only) with -g on x86_64-linux-gnu in 32-bit mode: running pass 'X86 Assembly Printer'"
   href="https://llvm.org/bugs/show_bug.cgi?id=31381">31381</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>clang crashes on valid code at -Os and -O2 (only) with -g on x86_64-linux-gnu in 32-bit mode: running pass 'X86 Assembly Printer'
          </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>llvm-bugs@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>$ clang -v
clang version 4.0.0 (trunk 289524)
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/4.9
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/4.9.4
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/5
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/5.3.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.3
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.4
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5.3.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.2.0
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Candidate multilib: x32;@mx32
Selected multilib: .;@m64
$
$ clang -m32 -Os -w small.c
$ clang -m64 -Os -g -w small.c
$
$ clang -m32 -Os -g -w small.c
clang-4.0:
/tmp/llvm-builder/llvm-source-trunk/lib/CodeGen/AsmPrinter/DwarfExpression.cpp:290:
void llvm::DwarfExpression::addFragmentOffset(const llvm::DIExpression*):
Assertion `FragmentOffset >= OffsetInBits && "overlapping or duplicate
fragments"' failed.
#0 0x0000000001f3d795 llvm::sys::PrintStackTrace(llvm::raw_ostream&)
(/usr/local/clang-trunk/bin/clang-4.0+0x1f3d795)
#1 0x0000000001f3b87e llvm::sys::RunSignalHandlers()
(/usr/local/clang-trunk/bin/clang-4.0+0x1f3b87e)
#2 0x0000000001f3b9e0 SignalHandler(int)
(/usr/local/clang-trunk/bin/clang-4.0+0x1f3b9e0)
#3 0x00007f4f59ccd330 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x10330)
#4 0x00007f4f58ab9c37 gsignal
/build/eglibc-oGUzwX/eglibc-2.19/signal/../nptl/sysdeps/unix/sysv/linux/raise.c:56:0
#5 0x00007f4f58abd028 abort
/build/eglibc-oGUzwX/eglibc-2.19/stdlib/abort.c:91:0
#6 0x00007f4f58ab2bf6 __assert_fail_base
/build/eglibc-oGUzwX/eglibc-2.19/assert/assert.c:92:0
#7 0x00007f4f58ab2ca2 (/lib/x86_64-linux-gnu/libc.so.6+0x2fca2)
#8 0x00000000024e7679 (/usr/local/clang-trunk/bin/clang-4.0+0x24e7679)
#9 0x00000000025285d7
llvm::DwarfCompileUnit::constructVariableDIEImpl(llvm::DbgVariable const&,
bool) (/usr/local/clang-trunk/bin/clang-4.0+0x25285d7)
#10 0x000000000252886c
llvm::DwarfCompileUnit::constructVariableDIE(llvm::DbgVariable&, bool)
(/usr/local/clang-trunk/bin/clang-4.0+0x252886c)
#11 0x0000000002528893
llvm::DwarfCompileUnit::constructVariableDIE(llvm::DbgVariable&,
llvm::LexicalScope const&, llvm::DIE*&)
(/usr/local/clang-trunk/bin/clang-4.0+0x2528893)
#12 0x000000000252d102
llvm::DwarfCompileUnit::createScopeChildrenDIE(llvm::LexicalScope*,
llvm::SmallVectorImpl<llvm::DIE*>&, unsigned int*)
(/usr/local/clang-trunk/bin/clang-4.0+0x252d102)
#13 0x000000000252cb3b
llvm::DwarfCompileUnit::constructScopeDIE(llvm::LexicalScope*,
llvm::SmallVectorImpl<llvm::DIE*>&)
(/usr/local/clang-trunk/bin/clang-4.0+0x252cb3b)
#14 0x000000000252d173
llvm::DwarfCompileUnit::createScopeChildrenDIE(llvm::LexicalScope*,
llvm::SmallVectorImpl<llvm::DIE*>&, unsigned int*)
(/usr/local/clang-trunk/bin/clang-4.0+0x252d173)
#15 0x000000000252cb3b
llvm::DwarfCompileUnit::constructScopeDIE(llvm::LexicalScope*,
llvm::SmallVectorImpl<llvm::DIE*>&)
(/usr/local/clang-trunk/bin/clang-4.0+0x252cb3b)
#16 0x000000000252d173
llvm::DwarfCompileUnit::createScopeChildrenDIE(llvm::LexicalScope*,
llvm::SmallVectorImpl<llvm::DIE*>&, unsigned int*)
(/usr/local/clang-trunk/bin/clang-4.0+0x252d173)
#17 0x000000000252cc23
llvm::DwarfCompileUnit::constructScopeDIE(llvm::LexicalScope*,
llvm::SmallVectorImpl<llvm::DIE*>&)
(/usr/local/clang-trunk/bin/clang-4.0+0x252cc23)
#18 0x000000000252d173
llvm::DwarfCompileUnit::createScopeChildrenDIE(llvm::LexicalScope*,
llvm::SmallVectorImpl<llvm::DIE*>&, unsigned int*)
(/usr/local/clang-trunk/bin/clang-4.0+0x252d173)
#19 0x000000000252cc23
llvm::DwarfCompileUnit::constructScopeDIE(llvm::LexicalScope*,
llvm::SmallVectorImpl<llvm::DIE*>&)
(/usr/local/clang-trunk/bin/clang-4.0+0x252cc23)
#20 0x000000000252d173
llvm::DwarfCompileUnit::createScopeChildrenDIE(llvm::LexicalScope*,
llvm::SmallVectorImpl<llvm::DIE*>&, unsigned int*)
(/usr/local/clang-trunk/bin/clang-4.0+0x252d173)
#21 0x000000000252d2c6
llvm::DwarfCompileUnit::createAndAddScopeChildren(llvm::LexicalScope*,
llvm::DIE&) (/usr/local/clang-trunk/bin/clang-4.0+0x252d2c6)
#22 0x000000000252d4cf
llvm::DwarfCompileUnit::constructSubprogramScopeDIE(llvm::LexicalScope*)
(/usr/local/clang-trunk/bin/clang-4.0+0x252d4cf)
#23 0x00000000024e2182 llvm::DwarfDebug::endFunction(llvm::MachineFunction
const*) (/usr/local/clang-trunk/bin/clang-4.0+0x24e2182)
#24 0x00000000024c41ef llvm::AsmPrinter::EmitFunctionBody()
(/usr/local/clang-trunk/bin/clang-4.0+0x24c41ef)
#25 0x000000000146a8aa
llvm::X86AsmPrinter::runOnMachineFunction(llvm::MachineFunction&)
(/usr/local/clang-trunk/bin/clang-4.0+0x146a8aa)
#26 0x00000000018a0a97
llvm::MachineFunctionPass::runOnFunction(llvm::Function&)
(/usr/local/clang-trunk/bin/clang-4.0+0x18a0a97)
#27 0x0000000001b6a493 llvm::FPPassManager::runOnFunction(llvm::Function&)
(/usr/local/clang-trunk/bin/clang-4.0+0x1b6a493)
#28 0x0000000001b6a53c llvm::FPPassManager::runOnModule(llvm::Module&)
(/usr/local/clang-trunk/bin/clang-4.0+0x1b6a53c)
#29 0x0000000001b6b1ea llvm::legacy::PassManagerImpl::run(llvm::Module&)
(/usr/local/clang-trunk/bin/clang-4.0+0x1b6b1ea)
#30 0x00000000020c334e clang::EmitBackendOutput(clang::DiagnosticsEngine&,
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-4.0+0x20c334e)
#31 0x0000000002725fdc
clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&)
(/usr/local/clang-trunk/bin/clang-4.0+0x2725fdc)
#32 0x0000000002b3a20c clang::ParseAST(clang::Sema&, bool, bool)
(/usr/local/clang-trunk/bin/clang-4.0+0x2b3a20c)
#33 0x0000000002720b5e clang::CodeGenAction::ExecuteAction()
(/usr/local/clang-trunk/bin/clang-4.0+0x2720b5e)
#34 0x0000000002414f9e clang::FrontendAction::Execute()
(/usr/local/clang-trunk/bin/clang-4.0+0x2414f9e)
#35 0x00000000023e9e0e
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/usr/local/clang-trunk/bin/clang-4.0+0x23e9e0e)
#36 0x00000000024a4e42
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/usr/local/clang-trunk/bin/clang-4.0+0x24a4e42)
#37 0x0000000000be2d50 cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) (/usr/local/clang-trunk/bin/clang-4.0+0xbe2d50)
#38 0x0000000000b84165 main (/usr/local/clang-trunk/bin/clang-4.0+0xb84165)
#39 0x00007f4f58aa4f45 __libc_start_main
/build/eglibc-oGUzwX/eglibc-2.19/csu/libc-start.c:321:0
#40 0x0000000000bdef0e _start (/usr/local/clang-trunk/bin/clang-4.0+0xbdef0e)
Stack dump:
0.      Program arguments: /usr/local/clang-trunk/bin/clang-4.0 -cc1 -triple
i386-unknown-linux-gnu -emit-obj -disable-free -main-file-name small.c
-mrelocation-model static -mthread-model posix -fmath-errno -masm-verbose
-mconstructor-aliases -fuse-init-array -target-cpu pentium4
-momit-leaf-frame-pointer -dwarf-column-info -debug-info-kind=limited
-dwarf-version=4 -debugger-tuning=gdb -resource-dir
/usr/local/clang-trunk/bin/../lib/clang/4.0.0 -internal-isystem
/usr/local/include -internal-isystem
/usr/local/clang-trunk/bin/../lib/clang/4.0.0/include -internal-externc-isystem
/include -internal-externc-isystem /usr/include -Os -w -fdebug-compilation-dir
/data2 -ferror-limit 19 -fmessage-length 178 -fobjc-runtime=gcc
-fdiagnostics-show-option -fcolor-diagnostics -vectorize-loops -vectorize-slp
-o /tmp/small-77a6e2.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 Assembly Printer' on function '@fn4'
clang-4.0: error: unable to execute command: Aborted (core dumped)
clang-4.0: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 4.0.0 (trunk 289524)
Target: i386-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/clang-trunk/bin
clang-4.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-4.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-4.0: note: diagnostic msg: /tmp/small-f62043.c
clang-4.0: note: diagnostic msg: /tmp/small-f62043.sh
clang-4.0: note: diagnostic msg:

********************
$


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


struct S

  int:24;
  char b;
  int c;
  int d:6;
} e, g;

int f, h;

void fn1 ()

  while (1)
    { 
      struct S i;
      if (f)
        g = i;
      i.d;
    }
}

void fn2 (struct S p)

  while (h)
    e = p;
}

void fn3 ()

  struct S l;
  fn2 (l);
  if (l.b)
    l.d = 0;
}


void fn4 ()

  if (h)
    { 
      fn3 ();
      fn1 ();
    }
}

int main ()

  fn4 ();
  return 0;
}</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>