<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/107703>107703</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[Clang] Assertion `!Traits::stopLess(b, a) && "Invalid interval"' failed.
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
yijan4845
</td>
</tr>
</table>
<pre>
Compiler Explorer: [https://godbolt.org/z/7rMGf5q4E](https://godbolt.org/z/7rMGf5q4E)
Attempting to compile the following valid program with Clang Assertion Trunk:
```c
#define ASIZE 0x80000000UL
extern void abort (void);
int __attribute__((noinline))
foo (const char *s) {
if (s[0] != 'a')
abort ();
return 0;
}
int __attribute__((noinline))
baz(long i) {
char s[ASIZE];
s[0] = 'a';
s[0] = 'a';
foo(s);
return 0;
}
```
Stack dump:
```
clang-20: /root/llvm-project/llvm/include/llvm/ADT/IntervalMap.h:633: unsigned int llvm::IntervalMapImpl::LeafNode<KeyT, ValT, N, Traits>::insertFrom(unsigned int&, unsigned int, KeyT, KeyT, ValT) [with KeyT = unsigned int; ValT = unsigned int; unsigned int N = 16; Traits = llvm::IntervalMapHalfOpenInfo<unsigned int>]: Assertion `!Traits::stopLess(b, a) && "Invalid interval"' 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: /opt/compiler-explorer/clang-assertions-trunk-20240907/bin/clang-20 -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -dumpdir /app/output.s- -disable-free -clear-ast-before-backend -main-file-name example.c -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=none -fmath-errno -ffp-contract=on -fno-rounding-math -fno-verbose-asm -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debug-info-kind=constructor -dwarf-version=4 -debugger-tuning=gdb -fdebug-compilation-dir=/app -fcoverage-compilation-dir=/app -resource-dir /opt/compiler-explorer/clang-assertions-trunk-20240907/lib/clang/20 -internal-isystem /opt/compiler-explorer/clang-assertions-trunk-20240907/lib/clang/20/include -internal-isystem /usr/local/include -internal-isystem /opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/15.0.0/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -O3 -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -fcolor-diagnostics -vectorize-loops -vectorize-slp -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/example-06c9d9.o -x c <source>
1. <eof> parser at end of file
2. Code generation
3. Running pass 'Function Pass Manager' on module '<source>'.
4. Running pass 'Assignment Tracking Analysis' on function '@baz'
#0 0x0000000003b24fa8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk-20240907/bin/clang-20+0x3b24fa8)
#1 0x0000000003b226ec SignalHandler(int) Signals.cpp:0:0
#2 0x000071f308842520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#3 0x000071f3088969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
#4 0x000071f308842476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
#5 0x000071f3088287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
#6 0x000071f30882871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
#7 0x000071f308839e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
#8 0x00000000032fa468 llvm::IntervalMapImpl::LeafNode<unsigned int, unsigned int, 16u, llvm::IntervalMapHalfOpenInfo<unsigned int>>::insertFrom(unsigned int&, unsigned int, unsigned int, unsigned int, unsigned int) (/opt/compiler-explorer/clang-assertions-trunk-20240907/bin/clang-20+0x32fa468)
#9 0x0000000003312aca llvm::IntervalMap<unsigned int, unsigned int, 16u, llvm::IntervalMapHalfOpenInfo<unsigned int>>::insert(unsigned int, unsigned int, unsigned int) (/opt/compiler-explorer/clang-assertions-trunk-20240907/bin/clang-20+0x3312aca)
#10 0x0000000003315239 (anonymous namespace)::MemLocFragmentFill::addDef(llvm::VarLocInfo const&, llvm::PointerUnion<llvm::Instruction const*, llvm::DbgRecord const*>, llvm::BasicBlock&, llvm::DenseMap<unsigned int, llvm::IntervalMap<unsigned int, unsigned int, 16u, llvm::IntervalMapHalfOpenInfo<unsigned int>>, llvm::DenseMapInfo<unsigned int, void>, llvm::detail::DenseMapPair<unsigned int, llvm::IntervalMap<unsigned int, unsigned int, 16u, llvm::IntervalMapHalfOpenInfo<unsigned int>>>>&) AssignmentTrackingAnalysis.cpp:0:0
#11 0x00000000033173e9 (anonymous namespace)::MemLocFragmentFill::run(FunctionVarLocsBuilder*) AssignmentTrackingAnalysis.cpp:0:0
#12 0x000000000331a0a8 analyzeFunction(llvm::Function&, llvm::DataLayout const&, FunctionVarLocsBuilder*) AssignmentTrackingAnalysis.cpp:0:0
#13 0x000000000331b057 llvm::AssignmentTrackingAnalysis::runOnFunction(llvm::Function&) (/opt/compiler-explorer/clang-assertions-trunk-20240907/bin/clang-20+0x331b057)
#14 0x0000000003494a60 llvm::FPPassManager::runOnFunction(llvm::Function&) (/opt/compiler-explorer/clang-assertions-trunk-20240907/bin/clang-20+0x3494a60)
#15 0x0000000003494e11 llvm::FPPassManager::runOnModule(llvm::Module&) (/opt/compiler-explorer/clang-assertions-trunk-20240907/bin/clang-20+0x3494e11)
#16 0x00000000034956c7 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/opt/compiler-explorer/clang-assertions-trunk-20240907/bin/clang-20+0x34956c7)
#17 0x0000000003dd1605 clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::StringRef, llvm::Module*, clang::BackendAction, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>, clang::BackendConsumer*) (/opt/compiler-explorer/clang-assertions-trunk-20240907/bin/clang-20+0x3dd1605)
#18 0x000000000446ef8e clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/opt/compiler-explorer/clang-assertions-trunk-20240907/bin/clang-20+0x446ef8e)
#19 0x00000000065ae3fc clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk-20240907/bin/clang-20+0x65ae3fc)
#20 0x000000000446f378 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk-20240907/bin/clang-20+0x446f378)
#21 0x00000000047012b9 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk-20240907/bin/clang-20+0x47012b9)
#22 0x0000000004684b6e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk-20240907/bin/clang-20+0x4684b6e)
#23 0x00000000047ea6de clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk-20240907/bin/clang-20+0x47ea6de)
#24 0x0000000000cb8fdf cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk-20240907/bin/clang-20+0xcb8fdf)
#25 0x0000000000cb222a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#26 0x0000000000cb5b5e clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk-20240907/bin/clang-20+0xcb5b5e)
#27 0x0000000000b88c84 main (/opt/compiler-explorer/clang-assertions-trunk-20240907/bin/clang-20+0xb88c84)
#28 0x000071f308829d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#29 0x000071f308829e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#30 0x0000000000cb1cde _start (/opt/compiler-explorer/clang-assertions-trunk-20240907/bin/clang-20+0xcb1cde)
clang: error: unable to execute command: Aborted (core dumped)
clang: error: clang frontend command failed due to signal (use -v to see invocation)
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzMWl1v2ziz_jXMDUFDomRZvsiFY8fb4qTboMn2AOfGoKiRwg1F6iWpNOmvPyAlx5LjfqTvZneD1oap4fB5hvMlSsxaUSuAczS_QPPNGevcnTbnT-JPptI8nZ8Vunw6X-umFRIMvnxspTZgULLCaH5x51xrUbJCdIvottZloaWbaVMjuv2K6HZhPvxWzf-TXqL5BtH858XpEkUbFK36z5Vz0LROqBo7jXkPBrs7wJWWUn_xFx6YFCVuja4Na_AX4e7wWjJV45W1YJzQCt-aTt375XvVWdT_48NvmpRQCQV4dfP-_y5x9JhH_d8fV70EPDowCj9oUWJWaOMworn_5eEmF72QUA7vdsw5I4rOwW6HaI5orrRQUijwontyldZeA9fKOszvmMGIriyiS4wWgzaMReVlLJpfRGi-wYjGKPFfC4bo4lkVxvgAaQwHYwOuMwpHz0NosXk11IJ9RTSXWtVYHAHEPXSPMBjOb3UyunqAPsKdXOAfShwEKq2DDSa8vsfseW_HXnTjGL_HZde0Bx84Jc292xAaBR-nW6O1Q3Qr5UNDWqP_BL7_iehWKC67Eg4Dq80totv3yoF5YPIDa2d3KFllSeK1dSoEW4m95cOEZIWS1Uj6fdPKfvAKWPW7LgEl6_-Bp1tE1_gzk-H7d_9xa5hwFiWXvbhQ3su3RjeI5uN1EM28-HRojfc6p7qXPqhD7PjxsB-TiclFEDx5YULu9yASZ_5CjzQMnOT8jsnqYwvqvao0StZTvb07rUZR7PeJxnv6Xpd1ur0CaxHNC8-FBSKed4YRpe9VnxvEsCSiFNEFrpiQUM76Pb--ulzdXGLbFY1wmOGiq7GB1geU0_gobwl31xUz7k293_Yj7xDWdmAR3WKm_MLBSULC4obZO1wwfu8M4-DhtgZaozlYCyW2ujP9sJ_JrNVcMAclNp3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