What is the hidden bug with the following statement?

assert(val++ != 0);



What is the hidden bug with the following statement? assert(val++ != 0);..

Answer / susie

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.

Is This Answer Correct ?    2 Yes 0 No

Post New Answer

More C Code Interview Questions

main() { int a[10]; printf("%d",*a+1-*a+3); }

1 Answers  


void main() { int x,y=2,z; z=(z*=2)+(x=y=z); printf("%d",z); }

4 Answers  


How we will connect multiple client ? (without using fork,thread)

3 Answers   TelDNA,


write a program to find out roots of quadratic equation "x=-b+-(b^2-4ac0^-1/2/2a"

2 Answers  


main() { int i=0; for(;i++;printf("%d",i)) ; printf("%d",i); }

1 Answers   Zoho,






Design an implement of the inputs functions for event mode

0 Answers   Wipro,


How to reverse a String without using C functions ?

33 Answers   Matrix, TCS, Wipro,


# include<stdio.h> aaa() { printf("hi"); } bbb(){ printf("hello"); } ccc(){ printf("bye"); } main() { int (*ptr[3])(); ptr[0]=aaa; ptr[1]=bbb; ptr[2]=ccc; ptr[2](); }

1 Answers  


How do I write a program to print proper subset of given string . Eg :input: abc output:{},{a},{b},{c},{a,b},{a,c},{b,c}, {a,b,c}.I desperately need this program please mail me to saravana6m@gmail.com

11 Answers   Deshaw, Infosys,


what is the code of the output of print the 10 fibonacci number series

2 Answers  


main() { int *ptr=(int*)malloc(sizeof(int)); *ptr=4; printf("%d",(*ptr)+++*ptr++); }

3 Answers   GNITC,


how can i cast a char type array to an int type array

2 Answers  


Categories