r/cpp • u/rsashka • Mar 13 '26
Trusted-CPP - Safe Software Developing in C++ with backward compatibility
https://trusted-cpp.org/I invite explore the concept of safe software developing in C++ while backward compatibility with legacy code. Please send feedback and constructive criticism on this concept and its implementation. Suggestions for improvement and assistance in the developint are also welcome.
26
Upvotes
View all comments
Show parent comment
3
u/aocregacc Mar 13 '26 edited Mar 13 '26
the vector is reset before the sort (
vect = {}). It passes all the sanitizers because libstdc++ just sets the size to 0 but keeps the allocation. You have to turn on_GLIBCXX_SANITIZE_VECTORfor asan to notice, and even then it only notices the access throughy, not the bad use ofx._GLIBCXX_DEBUGcatches that one I think, but the error message is a bit cryptic for me.edit: another thing I didn't realize is that
vect = {}invokes vector'soperator=(std::initializer_list), so it's not like you're move-assigning with an empty vector here. If you do, the allocation would be free'd in this case and asan would fire.