Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
C Programming
Short-circuiting in C
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="Thomas Richter, post: 4214470"] Sorry, I fail to see how this should work. Actually, a sufficiently smart compiler would reduce this to just the above, and in fact, a compiler can modify the code always on the basis of the "as-if" rule. So the question goes back to the OP what the intent of disabling the short-circuiting is. If it is to avoid two branches, then if a,b and c are always 0 or 1 (or any other number, identical for all three variables), you could simply write: if (a & b & c) { } If the intent is that an actual access of the variables happen, probably because they are hardware registers, then you would also suggest to declare them as volatile. However, typically the impact of such micro-optimizations is negligible. Question to the OP: Did you actually measure? Greetings, Thomas [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
C Programming
Short-circuiting in C
Top