Logo 
Search:

C Programming FAQ

Submit Interview FAQ
Home » Interview FAQ » C ProgrammingRSS Feeds

C programming practical question 159

  Shared By: Adah Miller    Date: Jan 24    Category: C Programming    Views: 67

Answer:

What is the hidden bug with the following statement?

assert(val++ != 0);


Answer & Explanation:
Assert macro is used for debugging and removed in release version. In assert, the experssion involves side-effects. So the behavior of the code becomes different in case of debug version and the release version thus leading to a subtle bug.
Rule to Remember:
Don’t use expressions that have side-effects in assert statements.

Share: 
 

Didn't find what you were looking for? Find more on C programming practical question 159 Or get search suggestion and latest updates.


Your Comment
  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].


Tagged: