Re: Function call evaluation order
- From: "Carl Daniel [VC++ MVP]" <cpdaniel_remove_this_and_nospam@xxxxxxxxxxxxxxx>
- Date: Thu, 23 Mar 2006 19:54:30 -0800
Frederico Pissarra wrote:
"Carl Daniel [VC++ MVP]"
The problem that precedence alone doesn't cover is that the relative
order of evaluation of the arguments of the three function calls is
not defined, nor is whether the evaluation of those arguments
overlaps.
Still... In the last example I show to you, here is the assembly
generated by compiling without optimizations (cl -Od -FAs -Fa -c
test.c) - of course the code sintax is a little more complex than
that... but it shows pos and pre increment in action...
You missed the point entirely - there's no issue here with understanding of
pre- and post-increment.
Code like the example that started this thread:
s.assign(data[i++]).append(data[i++]).append(data[i++]);
has undefined behavior.
Yes, it may do exactly what you hope it does, but it's not required to, and
there are reasonable code generation sequences where it does something
nearly opposite to what you expected.
-cd
.
- Follow-Ups:
- Re: Function call evaluation order
- From: Frederico Pissarra
- Re: Function call evaluation order
- References:
- Function call evaluation order
- From: Cheng
- Re: Function call evaluation order
- From: Frederico Pissarra
- Re: Function call evaluation order
- From: Carl Daniel [VC++ MVP]
- Re: Function call evaluation order
- From: Frederico Pissarra
- Function call evaluation order
- Prev by Date: Re: Function call evaluation order
- Next by Date: How to get notification in my application when a document it opened is modified
- Previous by thread: Re: Function call evaluation order
- Next by thread: Re: Function call evaluation order
- Index(es):
Relevant Pages
|