Evaluation order of assignment statement
- From: nachch@xxxxxxxxx
- Date: 23 Oct 2006 11:22:27 -0700
Does the C specification define the order of evaluation of assignment
statements?
For example, what should be the output from the following:
int foo1() { printf("foo1\n"); return 0; }
int foo2() { printf("foo2\n"); return 0; }
int foo3() { printf("foo3\n"); return 0; }
int main()
{
int array[1];
array[foo1()] = foo2() + foo3();
}
I'm asking this question since I'm getting conflicting results on
different compilers, and want to understand whether this is a compiler
bug or not.
gcc prints: foo1, foo2, foo3.
Microsoft Visual C prints: foo2, foo3, foo1.
Thanks.
.
- Follow-Ups:
- Re: Evaluation order of assignment statement
- From: Andrey Tarasevich
- Re: Evaluation order of assignment statement
- From: Walter Roberson
- Re: Evaluation order of assignment statement
- From: John Smith
- Re: Evaluation order of assignment statement
- Prev by Date: memcpy() problem
- Next by Date: Re: memcpy() problem
- Previous by thread: memcpy() problem
- Next by thread: Re: Evaluation order of assignment statement
- Index(es):
Relevant Pages
|