Re: Re: printf() print arguments in reversed order

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 8 December 2016 at 11:46, lhmouse wrote:
>> On 8 December 2016 at 07:13, lhmouse wrote:
>>> It is undefined behavior.
>>>
>>> The evaluation of three parameters in question is (at the moment) unsequenced.
>>> Since each of them  contains a function call, the three function calls are also
>>> unsequenced. The modify-and-read operations inside the function calls are
>>> unsequenced relative to each other. Hence the UB.
>>
>> No, that's incorrect. The functions don't interleave. It's unspecified
>> which order they execute in, but there is no undefined behaviour.
> I did ask a similar question on ##c++ on freenode and it seemed that people couldn't
> agree with each other. There were even opinions suggesting 'unspecified' be replaced
> with 'undefined' because it could be hard to distinguish it from the other.

No comment.

> Personally I think his code is UB because `printf` is a library function call hence
> is considered a 'side effect'. In spite that function calls don't interleave, changes of
> order of evaluation could produce different side effects and the result is undefined.

No, the result is unspecified. That's very different from undefined,
whatever some people on IRC might say.

The standard is clear that each invocation of the function body
completes before the next invocation begins.

This is off-topic for this list though.



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux