
8 Jul
2004
8 Jul
'04
12:12 a.m.
I'm not sure which of a/b/c I am, but if I saw the below code I would be surprised if foo() was not evaluated before bar(). If it was a function: f( foo(), bar() ); would foo() always be executed before bar()?
No. This is a common misconception and a common source of bugs that only show up when optimizations are turned on. It's also a source of exception-unsafe code, as detailed in Exceptional C++ and a GOTW column.
That kind of validates using v+=foo(),bar(); then, but also says why you shouldn't use it: a common source of bugs. I think with an initialization library in particular people will write, and expect to always work, something like: v+= get(), get(), get(); Darren