The poster made a trivial mistake and almost everyone answering gleefully pointed it out instead of fixing it and discussing the actual question. Yes, maybe it's a silly one but that's not the reason to gang up on the poster. Even the accepted "answer" consists of the compiler output with errors which has nothing to do with what's asked.
If I'm an outsider this would give me an impression that SO users is a bunch of jaded self-important "experts" who won't deign to answer unless you ask something obscure that tickles their brain cells.
Also, "closed as not a real question"? How is it not a question?
EDIT the question has been deleted so here's the cached copy from my RSS:
In terms of assembly or machine code, is there any difference between these two piece of code? Note: a is user's input. First:
int a = 10; bool b = false; if (a > 5) b = true; // just changing the value
int a = 10; if (a > 5) bool b = true; // declaration placed here ... else bool b = false;
I'm thinking of Eliminating the Else part, in terms of micro-optimisation. Regardless of how much it will speed up the code, my question is, is there any difference between above codes in the compiled binary or not?
The mistake was putting the declaration of
b inside the
else, but it's obvious IMO what he's actually asking. And before you accuse him of not checking if it compiles, have you never done the same thing? Edited the code before posting to emphasize something and did not double check because "it was a minor change, surely it's still valid code"?
EDIT2 Question has been undeleted, thanks!