Re: unexpected result
- From: Keith Thompson <kst-u@xxxxxxx>
- Date: Fri, 10 Mar 2006 07:02:04 GMT
jaysome <jaysome@xxxxxxxxxxx> writes:
Jack Klein wrote:[...]
[...]ashu wrote:
[...]include <stdio.h>
int main(void)
{
int i,j=2;
i=j++ * ++j * j++;
printf("%d %d",i,j);
return 0;
}
No, it is not "all compiler dependent", it is undefined behavior.
There is no right result, there is no wrong result, as far as the C
language is concerned there is no need for a result at all.
There's always a result. But the result may not be as expected. Hence
unexpected behavior.
No, there is not always a result. One of the infinitely many possible
consequences of undefined behavior is that the code might not compile
in the first place. Other possibilities are that the program could do
nothing at all, or format your hard drive, or melt your monitor, or
make demons fly out of your nose.
--
Keith Thompson (The_Other_Keith) kst-u@xxxxxxx <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
.
- Follow-Ups:
- Re: unexpected result
- From: jaysome
- Re: unexpected result
- References:
- unexpected result
- From: ashu
- Re: unexpected result
- From: Ankur
- Re: unexpected result
- From: Jack Klein
- Re: unexpected result
- From: jaysome
- unexpected result
- Prev by Date: Some problem on macro declaration in C again
- Next by Date: Re: diff memcpy and memmove
- Previous by thread: Re: unexpected result
- Next by thread: Re: unexpected result
- Index(es):
Relevant Pages
|