3 ms·
I'm curious whether any of the standard source code analysis tools would have caught this.
by Twirrim 11y ago
I'm curious whether any of the standard source code analysis tools would have caught this.
- Etheryte 11y agoI doubt it, as the buggy code wasn't nonsense in the usual sense.
- Someone 11y agoBut it was suspicious. Seeing 1 * sizeof(int) directly in the code, not in a macro expansion, in my book is somewhat suspicious (people could do that for symmetry in a series of similar lines of code), but whatever_count + x * sizeof(int) could easily trigger a heuristic "thou shalt not add a count and a size" The code does not even need to be smart enough to determine that "whatever_count" is used as a count; if it actually is a size, it is worth warning about, too, so a somewhat vague warning would, in my book, be fine.
- HappyTypist 11y agoThat makes sense. If it's not there, it's probably something that should be added.
- tomyws 11y agoMe to. The compiler would need to output at any optimization passes which handle multiplication factorization, which could be quite lengthy!