3 ms·
> he claimed it to be a halting problem and that the compiler couldn't determine that all paths didnt return a value. Theoretically we can't determine whether
by im3w1l 7y ago
> he claimed it to be a halting problem and that the compiler couldn't determine that all paths didnt return a value.
Theoretically we can't determine whether a function will return a value or not. In practice, heuristics get 99% of the way and the last 1% you can make the programmer put in a possibly redundant return statement.
- adrusi 7y agoThere are two different questions: "do all paths lead to returning a value?" and "will the function return a value?" Answering the second in the general case is equivalent to solving the halting problem. But answering the first question is much simpler. Static analyzers aren't using a heuristic approach to the second question, they're solving a completely different problem.
- mortb 7y agoDon't get me wrong, but if whole classes of errors, can be avoided by not choosing C++, why should I choose to use it?
- monsieurbanana 7y agoBecause you already know C++ and don't want or can't justify learning another language. That's a very valable reason.