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

Re: Implementation-defined behaviour

Subject: Re: Implementation-defined behaviour
From: "Dann Corbit"
Date: Fri, 28 Mar 2008 00:06:15 -0700
Newsgroups: comp.lang.c

"Barry Schwarz" <schwarzb@xxxxxxxx> wrote in message 
news:c80pu39ghqdnumqju6mk2qgktt751hb7bn@xxxxxxxxxx
> On Thu, 27 Mar 2008 20:19:35 -0700, "Dann Corbit" <dcorbit@xxxxxxxxx>
> wrote:
>
>>"Ioannis Vranos" <ivranos@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
>>news:fshjmg$1avp$1@xxxxxxxxxxxxxxxxxxxxxx
>>> AFAIK the following is implementation-defined behaviour, am I right?:
>>>
>>>
>>> #include <stdio.h>
>>>
>>>
>>> int main(void)
>>> {
>>> int n= 0;
>>>
>>> printf("%d\n", n++);
>>>
>>>
>>> return 0;
>>> }
>>
>>C:\tmp>lin foo.c
>>
>>C:\tmp>"C:\Lint\Lint-nt"  +v  -i"C:\Lint"  std.lnt  -os(_LINT.TMP) foo.c
>>PC-lint for C/C++ (NT) Vers. 8.00u, Copyright Gimpel Software 1985-2006
>>
>>--- Module:   foo.c (C)
>>
>>C:\tmp>type _LINT.TMP   | more
>>
>>--- Module:   foo.c (C)
>>                            _
>>    printf("%d %d\n", n++, n);
>>foo.c(8) : Warning 564: variable 'n' depends on order of evaluation
>
> The correct diagnostic would state: without an intervening sequence
> point, n is modified and also evaluated for a purpose other than
> determining the modified value.  This invokes undefined behavior.

The examination of n in the last parameter of printf() is to determine its 
value.
I am not sure that your interpretation is certain.  Are you sure of it?



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


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