I have such dilemma. Maybe someone will consider this opinion based, but I am sure this is relevant for many projects and also maybe someone will give answer which is not opinion based.
Imagine I was given large C++ project, which works correctly for many years (some may say this doesn't mean much if there is UB but come on, it means something).
Now, imagine two situations:
- there is either (undefined behaviour) UB in code but it still works as I mentioned
- there is no UB
Let's take first scenario.
Now if there is UB (and many instances of it) and project has been working fine I guess it is best to not touch project.
But what if I want to add feature to the project, what to do?
In such case:
- adding even new library to project increases risk of project to stop working well
- Recompiling with new compiler increases risk to make project stop working well
So, if there is UB, in the code, and it has been working fine, what to do if one wants to add new features to it? Without increasing risks that project will stop working correctly?
Is fixing all UB realistic in large C++ project by just code inspection? If no, we go to the point, when adding new features may break working project because it has been working well so far (please see two bullets points above).
Or maybe one tells the management because of such situation it is safest to not add anything to the project.
I hope I made my question clear.
I am pretty sure this is common situation, how do people proceed in such cases?