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

Re: Implementation-defined behaviour

Subject: Re: Implementation-defined behaviour
From: Barry Schwarz
Date: Thu, 27 Mar 2008 22:23:54 -0700
Newsgroups: comp.lang.c

On Fri, 28 Mar 2008 05:18:31 +0200, Ioannis Vranos
<ivranos@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:

>Ian Collins wrote:
>> Ioannis Vranos wrote:
>>> Eric Sosman wrote:
>>>> Ioannis Vranos wrote:
>>>>> 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;
>>>>> }
>>>>     Only by quibbles: the form of "successful termination"
>>>> returned to the host environment is implementation-defined,
>>>> the actual new-line representation written to stdout in
>>>> response to the '\n' is implementation-defined, and things
>>>> of that sort.
>>>>
>>>>     What aspect do you believe is not Standard-defined?
>>>
>>> I am talking about the implementation-defined behaviour of the printf()
>>> call described at 2.12 of K&R2.
>>>
>> There's nothing wrong with your example, the one you cite is completely
>> different.  If you had tried to use n again in the printf, you would hit UB.
>
>
>So, printf("%d "%d\n", x++, x++); invokes implementation-defined

This invokes undefined behavior.  The commas separating function
arguments are not sequence points.  You are modifying x twice without
an intervening sequence point.

>behaviour, while printf("%d\n", x++); doesn't invoke
>implementation-defined behaviour?


Remove del for email

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