3 ms·
As much as I like the premise of the article, I see two serious problems, that would need to be resolved for the "magic wand" tool to be useful, and it's not ve
by akavel 11y ago
As much as I like the premise of the article, I see two serious problems, that would need to be resolved for the "magic wand" tool to be useful, and it's not very obvious for me how:
1. What about templates? If there's a "template<T> void foo(x &T)", and it does "x++" inside, and I sometimes use it on int, sometimes on bool, how would the magic wand upgrade only the bool cases to "x = true"? (And please don't tell me "then you have borked codebase, u go fix it, man!" In C++, you have codebase you have, sometimes decades of legacy code you hope to upgrade bit by bit "when time, boss and priorities permit".)
Similarly, if the template does "x = 0;", how could the magic wand upgrade only the cases where T is a pointer, to "x = nullptr;"?
2. One more important, yet not mentioned feature of the magic wand tool, would be that it'd have to be flawless! If the tool has bugs, it could break my codebase without me knowing, till it's too late. Especially tricky here is how would the tool behave on code with undefined behavior; after years of working with C++, I have a nagging suspicion that virtually every sizable C++ codebase does actually have some undefined behavior lurking somewhere.
- eru 11y ago> [...] I have a nagging suspicion that virtually every sizable C++ codebase does actually have some undefined behavior lurking somewhere. You are being too optimistic. Any C++ code base over at most a couple hundred very carefully crafted lines will have undefined behaviour and implementation specified behaviour.
- fauigerzigerk 11y ago>1. What about templates? If there's a "template<T> void foo(x &T)", and it does "x++" inside, and I sometimes use it on int, sometimes on bool, how would the magic wand upgrade only the bool cases to "x = true"? Generate a new template specialization or overload? I realize this could be rather questionable if the offending operator use is somewhere in the middle of other code.