This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: printf() print arguments in reversed order


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.

The C++ standard says:
"For each function invocation F, for every evaluation A that occurs
within F and every evaluation B that does not
occur within F but is evaluated on the same thread and as part of the
same signal handler (if any), either A is
sequenced before B or B is sequenced before A."

So they're not unsequenced.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]