comp.lang.c
[Top] [All Lists]

Re: Implementation-defined behaviour

Subject: Re: Implementation-defined behaviour
From: CBFalconer
Date: Fri, 28 Mar 2008 19:39:42 -0500
Newsgroups: comp.lang.c

pete wrote:
> Ioannis Vranos wrote:
>
... snip ...
>
>> K&R2 mentions the following:
>>
>> "printf("%d %d\n", ++n, power(2,n));   /* WRONG */
>>
>> can produce different results with different compilers, depending
>> on whether n is incremented before power is called".
>>
>> That's why I call it implementation-defined behaviour.
> 
> It's unspecified behavior.  The power(2,n) function call,
> introduces a sequence point that the other code examples don't
> have.  This is all about sequence points.

Not quite.  Also order of parameter evaluation.  The power function
can be called before the ++n is executed, or the reverse.  As K&R
pointed out.

-- 
 [mail]: Chuck F (cbfalconer at maineline dot net) 
 [page]: <http://cbfalconer.home.att.net>
            Try the download section.



-- 
Posted via a free Usenet account from                                 www.teranews.com">http://www.teranews.com


<Prev in Thread] Current Thread [Next in Thread>
Privacy Policy