3 ms·
C has lots of undefined behavior unrelated to ++ (which only adds a small twist in the grand scheme of things). In C afaik f(g(),h()) is still UB because eithe
by beagle3 6y ago
C has lots of undefined behavior unrelated to ++ (which only adds a small twist in the grand scheme of things).
In C afaik f(g(),h()) is still UB because either g() or h() could be called first. ++ is just another small detail. (And no, I didn’t know C++17 made that behavior defined. Do you have a quick description of how it is defined now?)
“Newer languages like rust” - just say “rust”, unless you have another good example of a non fringe language that adopted most c syntax including += but without ++.
- bregma 6y ago`f(g(),h())` is not UB. The order of evaluation of parameters is unspecified, but it's not undefined. They will be evaluated in some order before the call to `f()` takes place. If both functions modify the same global state, the order of modification is unspecified. It's still not undefined, and your use of global variables is still not recommended.
- gonzus 6y agoZig did too.