Rust and GCC, two different ways
Rust and GCC, two different ways
Posted Oct 11, 2021 6:46 UTC (Mon) by eru (subscriber, #2753)In reply to: Rust and GCC, two different ways by marcH
Parent article: Rust and GCC, two different ways
Undefined behaviour does not always mean "random" behaviour. The same compiler is likely to do some things in the same way, regardless of target, even though your language definition might say the result is undefined, or fails to define it. For example, suppose the spec of the language with just one implementation does not say in which order function parameters are evaluated. So it is is undefined, although not explicitly. But as it happens, the compiler always evaluates them left-to-right, due to the decisions of its implementer. Lots of code is then written that works fine with this compiler.
Then along comes another, independent implementation, whose author has seen it useful to sometimes use another evaluation order. It is 100% certain that some of the code that ran with the original compiler fails with the new because of this, even though both follow the spec.
