This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/11633] g++ does not initialize structures when auto-increment variables are used
- From: "msimons at simons-clan dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 22 Jul 2003 23:19:58 -0000
- Subject: [Bug c++/11633] g++ does not initialize structures when auto-increment variables are used
- References: <20030722205341.11633.msimons@simons-clan.com>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11633
------- Additional Comments From msimons at simons-clan dot com 2003-07-22 23:19 -------
A friend pointed out language in the gcc.info file which appears to cover
the 'comma' ordering case:
===
* Making side effects happen in the same order as in some other
compiler.
It is never safe to depend on the order of evaluation of side
effects. For example, a function call like this may very well
behave differently from one compiler to another:
void func (int, int);
int i = 2;
func (i++, i++);
There is no guarantee (in either the C or the C++ standard language
definitions) that the increments will be evaluated in any
particular order. Either increment might happen first. `func'
might get the arguments `2, 3', or it might get `3, 2', or even
`2, 2'.
===
I'm not sure if this applies here... and if it *does* apply it seems
inconsistant that things like: ++foo-1, ++foo-1 ... foo++ + 0, foo++ + 0 ...
and value(), value()... all get evaluated left to right, but foo++, foo++ value
gets looked up once, and gets somehow the increment happens N times.
I am very interested in what the c++ language lawyers have to say about this
sample. If it is truely undefined I am *amazed* that practically all of the
remaining commercial unix, c++ compilers do it the same way.