4 ms·
Indeed, however every programmer no matter how good will make mistakes sometimes. It can be in 1%, 0.1%, 0.01% of LoC. Loosing attention can be so easy, it can
by vmarsy 10y ago
Indeed, however every programmer no matter how good will make mistakes sometimes. It can be in 1%, 0.1%, 0.01% of LoC. Loosing attention can be so easy, it can be a co-worker walking by, an important email/meeting happening while you were focused on a 'copy-pasting' step.
Having a tool that is trained to spot this kind of human errors is good. It can be useful in any language, not only C++. Avoiding them in the first place and giving you advices on how to not do it again would be a nice thing compiler could provide. i.e:
a[0] = b[0];
a[1] = b[1];
a[2] = b[0];
^ warning: Are you sure you want to assign b[0] to a[2]. If not, consider rewriting your code with a for loop
a[3] = b[3];
- acqq 10y agoThe author of the article actually develops the tool that can help the programmers detect such errors. The compilers don't report such kind of errors because it was traditionally to expensive to detect them. The special tool, like the one mentioned in the article, doesn't have to produce the optimized code and doesn't have to be run as frequently as on each compilation but it can allow the programmer to detect potential problems. It's surely worth using it.