2 ms·
Right, and in trivial cases that works. But if you've got, for example int x; if (somethingThatYouKnowIsTrueButTheCompilerDoesnt()) x = 3; th
by TheLoneWolfling 12y ago
Right, and in trivial cases that works.
But if you've got, for example
int x;
if (somethingThatYouKnowIsTrueButTheCompilerDoesnt())
x = 3;
there's no way to express that with either of those methods. You'll end up with the redundant store.
- WalterBright 12y agoIf you know it is always true, why is it in an if() ? You'd right it as: int x; if (somethingThatYouKnowIsTrueButTheCompilerDoesnt()) x = 3; else assert(0); and the compiler will remove the redundant store to x.