News for hackers. Stuff that matters.
Re:My favourite C++ footgun by dfox on Wednesday June 23, 2021 @05:11AM (#27602432)
It is unspecified, not undefined.
Re:My favourite C++ footgun by the-dude on Wednesday June 23, 2021 @05:13AM (#27602442)
Thanks for the correction. What does it mean?
Re:My favourite C++ footgun by palunon on Wednesday June 23, 2021 @05:36AM (#27602557)
The order of parameter evaluation is not specified by the standard, so if your program behavior is relying on it it may be incorrect. But relying on it doesn't instantly make your whole program completely meaningless, nasal demons and all.

> Certain other aspects and operations of the abstract machine are described in this International Standard as unspecified (for example, order of evaluation of arguments to a function). Where possible, this International Standard defines a set of allowable behaviors. These define the nondeterministic aspects of the abstract machine.

> Certain other operations are described in this International Standard as undefined (for example, the effect of dereferencing the null pointer). [ Note: this International Standard imposes no requirements on the behavior of programs that contain undefined behavior. β€”end note ]

Re:My favourite C++ footgun by bestouff on Wednesday June 23, 2021 @06:05AM (#27602723)
"Unspecified behavior" means something correct will happen, but you don't know what (in that case you can't rely on the execution order). "Undefined behavior" means something entirely incorrect may happen (crash or totally unexpected and bad behavior, so the term "nasal daemons" which means dragons coming out of your nose).
Re:My favourite C++ footgun by barrkel on Wednesday June 23, 2021 @05:32AM (#27602537)
If it was undefined, then anything could happen (nasal demons), but that would be silly: you wouldn't be able to safely call functions with multiple side-effecting arguments at all.

Unspecified means that you can't rely on the order of evaluation. "Anything" may not happen; the compiler controls the sequencing.