r/cpp • • 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.

28 Upvotes

15 comments sorted by

View all comments

Show parent comment

11

u/MysticTheMeeM Mar 13 '26

Immediately above the call to sort, the vector is assigned a new value, that invalidates the iterators.

OPs system then infers those are invalid and produces an error on the subsequent two lines (both the begin iterator and reference to first element no longer refer to valid data).

2

u/ts826848 Mar 14 '26

Oh duh, can't believe I missed that. Thanks!

1

u/germandiago Mar 16 '26

Took me also a couple of reads to detect it. But when I saw error comment I was sure it was me lol.