<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/83617>83617</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Segfault when using LTO
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
victorstewart
</td>
</tr>
</table>
<pre>
using Clang 17.0.6 to compile a C++ program, got this segfault when turning on `-flto`. but without using lto, segfault never occurs.
```
Program terminated with signal SIGSEGV, Segmentation fault.
#0 std::vector<unsigned int, std::allocator<unsigned int> >::size (this=0x39) at /usr/lib64/gcc/x86_64-generic-linux/13/../../../../include/c++/13/bits/stl_vector.h:989
989 size() const _GLIBCXX_NOEXCEPT
[Current thread is 1 (Thread 0x55c8ac52de40 (LWP 12494))]
(gdb) bt
#0 std::vector<unsigned int, std::allocator<unsigned int> >::size (this=0x39) at /usr/lib64/gcc/x86_64-generic-linux/13/../../../../include/c++/13/bits/stl_vector.h:989
#1 libbgp::BgpPathAttribCommunity::length (this=0x1) at bgp-path-attrib.cc:1468
#2 0x000055c8ac4d9817 in _Unwind_ForcedUnwind_Phase2 () at ../../../gcc-13.1.0/libgcc/unwind.inc:171
#3 0x000055c8ac4da177 in _Unwind_Resume () at ../../../gcc-13.1.0/libgcc/unwind.inc:244
#4 0x000055c8ac82cf0f in std::__new_allocator<std::_Sp_counted_ptr_inplace<libbgp::BgpPathAttribCommunity, std::allocator<void>, (__gnu_cxx::_Lock_policy)2> >::deallocate (__p=0x55c8ae5226e0,
__n=1, this=<optimized out>) at /usr/include/c++/13/bits/new_allocator.h:172
#5 std::allocator<std::_Sp_counted_ptr_inplace<libbgp::BgpPathAttribCommunity, std::allocator<void>, (__gnu_cxx::_Lock_policy)2> >::deallocate (__p=0x55c8ae5226e0, __n=1, this=<optimized out>)
at /usr/include/c++/13/bits/allocator.h:210
#6 std::allocator_traits<std::allocator<std::_Sp_counted_ptr_inplace<libbgp::BgpPathAttribCommunity, std::allocator<void>, (__gnu_cxx::_Lock_policy)2> > >::deallocate (__p=0x55c8ae5226e0,
__n=1, __a=...) at /usr/include/c++/13/bits/alloc_traits.h:517
#7 std::__allocated_ptr<std::allocator<std::_Sp_counted_ptr_inplace<libbgp::BgpPathAttribCommunity, std::allocator<void>, (__gnu_cxx::_Lock_policy)2> > >::~__allocated_ptr (this=<optimized out>)
at /usr/include/c++/13/bits/allocated_ptr.h:74
#8 std::__shared_count<(__gnu_cxx::_Lock_policy)2>::__shared_count<libbgp::BgpPathAttribCommunity, std::allocator<void>, BGPHub*> (this=<optimized out>, __p=<optimized out>, __a=...,
__args=<optimized out>) at /usr/include/c++/13/bits/shared_ptr_base.h:976
#9 std::__shared_ptr<libbgp::BgpPathAttribCommunity, (__gnu_cxx::_Lock_policy)2>::__shared_ptr<std::allocator<void>, BGPHub*> (this=<optimized out>, __tag=..., __args=<optimized out>)
at /usr/include/c++/13/bits/shared_ptr_base.h:1712
#10 std::shared_ptr<libbgp::BgpPathAttribCommunity>::shared_ptr<std::allocator<void>, BGPHub*> (this=<optimized out>, __tag=..., __args=<optimized out>)
at /usr/include/c++/13/bits/shared_ptr.h:464
#11 std::make_shared<libbgp::BgpPathAttribCommunity, BGPHub*> (__args=<optimized out>) at /usr/include/c++/13/bits/shared_ptr.h:1009
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzkl1tv2zYfxj8NfUNY4EHHC1_YSpy3QPA2WLqtdwJFMRJXmRRIKnF7sc8-kFLsOHPb9ASsGxAoUSjy-T-__6MDmbWyVUKsQLIBycWCja7TZnUvudPGOvHAjFvUunm_Gq1ULSx7plqIswhFKXQacr0bZC8ggyUgG0A2cDC6NWwHSAlb7aDrpIVWtHds7B186ISCbjTKr6UVBCla3vVOgxRFsB4dfJCu06ODk5ofIeVxuhL3wkDN-WhsBNAFQOv5mKL5J5zeTDVAJ8xOKuZEExaG3ivr4e2rq9vLq9_80rei3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