This is not true of comments.
If we could make outdated comments produce compilation errors, we would live in a wonderful world :)
This is not true of comments.
If we could make outdated comments produce compilation errors, we would live in a wonderful world :)
> If we could make outdated comments produce compilation errors, we would live in a wonderful world
It is impossible. The whole point of having comments (and also identifiers) is to tie the code to things that are not formally described. If we would formally describe them, they would become the code.
You could, at best, mark identifiers in comments (and what their refer to), and then you could use this to hint at comments that need to be updated (as somebody else mentioned). But it will never be a perfect process, because there will always be a boundary between formal and informal.
Doxygen supports documenting function parameters, C++ template parameters, return values then Doxygen and Clang can tell if the name listed for some of those things doesn't match the actual code or if a certain kinds of comments are missing. This won't tell you the documentation is wrong, but it would stop you from adding or removing a function parameters while ignoring documentation comments entirely.
If you want to go crazy you can write Clang plugins using LibTooling and run and code you want and analyze the comments any way you choose.
I really hate it when the compiler ignores my comments.
Depends what language you are working in; in some it won't fail until runtime.