Hello
I would recommend you to rewrite the code as follows:
j++;
Foo( buffer[j], j );
Article 6.3.2.2 in the ANSI standard specifies that
"The order of evaluation of the function designator , the arguments and subexpressions within the arguments is unspecified <...>".
So that means when you are writing
Foo( buffer[++j], j );
the standard does not specify which parameter is evaluated first. Might be the first one or the second one.
When -O3 is activated the compiler is passing second parameter first and then the first one.
This is compliant to the standard and I am not sure we can call that a bug.
CrasyCat