<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/89571>89571</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
clang crashes when both '-lstdc++' '-ccc-print-phases' are on the command line
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
pudh4418
</td>
</tr>
</table>
<pre>
The following command line causes an assertion:
`clang -o m m.cpp -lstdc++ -ccc-print-phases`
```
+- 0: input, "m.cpp", c++
+- 1: preprocessor, {0}, c++-cpp-output
+- 2: compiler, {1}, ir
+- 3: backend, {2}, assembler
+- 4: assembler, {3}, object
clang: /data/A/llvm-project/llvm/include/llvm/ADT/SmallVector.h:308: const T& llvm::SmallVectorTemplateCommon<T, <template-parameter-1-2> >::operator[](llvm::SmallVectorTemplateCommon<T, <template-parameter-1-2> >::size_type) const [with T = const char*; <template-parameter-1-2> = void; llvm::SmallVectorTemplateCommon<T, <template-parameter-1-2> >::const_reference = const char* const&; llvm::SmallVectorTemplateCommon<T, <template-parameter-1-2> >::size_type = long unsigned int]: Assertion `idx < size()' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0. Program arguments: /data/A/llvm-project/build/bin/clang -o m m.cpp -lstdc++ -ccc-print-phases
1. Compilation construction
#0 0x00005590ffdbfdd2 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (.localalias) /data/A/llvm-project/llvm/lib/Support/Unix/Signals.inc:723:22
#1 0x00005590ffdc01e8 PrintStackTraceSignalHandler(void*) /data/A/llvm-project/llvm/lib/Support/Unix/Signals.inc:798:1
#2 0x00005590ffdbd76e llvm::sys::RunSignalHandlers() (.localalias) /data/A/llvm-project/llvm/lib/Support/Signals.cpp:105:20
#3 0x00005590ffdbf68c SignalHandler(int) /data/A/llvm-project/llvm/lib/Support/Unix/Signals.inc:413:1
#4 0x00007fdf9d4a8420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
#5 0x00007fdf9cf4500b raise /build/glibc-wuryBv/glibc-2.31/signal/../sysdeps/unix/sysv/linux/raise.c:51:1
#6 0x00007fdf9cf24859 abort /build/glibc-wuryBv/glibc-2.31/stdlib/abort.c:81:7
#7 0x00007fdf9cf24729 get_sysdep_segment_value /build/glibc-wuryBv/glibc-2.31/intl/loadmsgcat.c:509:8
#8 0x00007fdf9cf24729 _nl_load_domain /build/glibc-wuryBv/glibc-2.31/intl/loadmsgcat.c:970:34
#9 0x00007fdf9cf35fd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)
#10 0x00005590fda2d295 llvm::SmallVectorTemplateCommon<char const*, void>::operator[](unsigned long) const /data/A/llvm-project/llvm/include/llvm/ADT/SmallVector.h:309:19
#11 0x00005590fda2b15b llvm::opt::Arg::getValue(unsigned int) const /data/A/llvm-project/llvm/include/llvm/Option/Arg.h:126:20
#12 0x0000559100bc2e72 PrintActions1(clang::driver::Compilation const&, clang::driver::Action*, std::map<clang::driver::Action*, unsigned int, std::less<clang::driver::Action*>, std::allocator<std::pair<clang::driver::Action* const, unsigned int> > >&, llvm::Twine, int) /data/A/llvm-project/clang/lib/Driver/Driver.cpp:2342:46
#13 0x0000559100bc3143 PrintActions1(clang::driver::Compilation const&, clang::driver::Action*, std::map<clang::driver::Action*, unsigned int, std::less<clang::driver::Action*>, std::allocator<std::pair<clang::driver::Action* const, unsigned int> > >&, llvm::Twine, int) /data/A/llvm-project/clang/lib/Driver/Driver.cpp:2375:79
#14 0x0000559100bc34f3 clang::driver::Driver::PrintActions(clang::driver::Compilation const&) const (.localalias) /data/A/llvm-project/clang/lib/Driver/Driver.cpp:2415:18
#15 0x0000559100bbdcd2 clang::driver::Driver::BuildCompilation(llvm::ArrayRef<char const*>) /data/A/llvm-project/clang/lib/Driver/Driver.cpp:1522:12
#16 0x00005590fda28ff2 clang_main(int, char**, llvm::ToolContext const&) /data/A/llvm-project/clang/tools/driver/driver.cpp:361:66
#17 0x00005590fda62e6a main /data/A/llvm-project/build/tools/clang/tools/driver/clang-driver.cpp:17:20
#18 0x00007fdf9cf26083 __libc_start_main /build/glibc-wuryBv/glibc-2.31/csu/../csu/libc-start.c:342:3
#19 0x00005590fda273ee _start (/data/A/llvm-project/build/bin/clang+0x30683ee)
Aborted
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsWEtv67gV_jX0hrBBkXp54YUcx-iiQAdz09kKFEnL7EikQFJ59NcXJGVL9p3b63TSRYEGQaLH4TnfefA7h6LWylYJsQPZHmSHFR3dWZvdMPJzmiblqtH8Y_dyFvCku06_SdVCpvueKg47qQRkdLTCQqogtVYYJ7UCpALoANDlb45YR1UL1xr2sN-wYYDrzjrOAN4DvIdrxth6MFK59XCmVliQozsF02-4hYsfgPdriACpoFTD6AB-ggDjYANg7G8nI9PSIJ94-cGIwWgmrNUmLCv2CBSHxZI1G4a1Hp3XuzAcVGCvgul-kJ24LE-m5dJcxYMs8bINZb8LxSdRPIn6kPWNVxEd9eKpF59fxAVkWqCbfwg2wQlB9cIAHzl1FOBjBfCx61779WB0EIy3AB-lYt3IxfygOrwAfPzW0677TTCnzeYMSEVQGT1T1sEXgHMYxEkFSLWQfRH90FEnnnTf-3w_vQSc5MlNL9YDNbQXTph1ssaAPENAnqMaPQhDnTax3gAuv9yClf8UtfsYBMDbyRWQ7d-kO8MXCMhhesbO1ABcAbL_md4DfNWSe8Evxxqg1EachBGKie_hxTuA8_-K-WuoguFOqxaOKhACh1I5nyBSweqysyHIkeTvXjn0SwEuAd4CXMATlZ3gm1iZv_z1ufr2DO3Y9NJBCpuxhUYM2jjoNDw7N1hvHh8BPrbSncdmw3Q_1-ZdCUtrR2EBPkLPOlMlQ3cWkBlqz2FvOUOZ8H7P-1pwaPVo4mO_klqrmaROcGhGBS0zcnAT5G-Ost8hH_vhyl5oA9D2F6NbQ3tITTv2Qj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