2014-07-03 16:41 GMT+01:00 Patrick Serru: > Hi All, > > I have a philosophical problem with the gcc compiler. At school, I seem to > have learned that Expression were evaluated from left to right when they are > separated by a comma. I do not understand why this is not applied when it > comes to passing parameters to a function. So I find that if I write: > void foo (int a, int b, int c); > then: > foo (a, b, a + = 1); > 1st and 3rd arguments have the same value. > > You may say, the order of which we told you about in school relates an > expression that is not a sequence of parameters (?). Correct. Comma operators within an expression affect evaluation order, but the commas between function arguments are not comma operators. As it says in the C FAQ (http://c-faq.com/expr/comma.html) if the commas separating function arguments were comma operators then no function could receive more than one argument. Just because the same character is used doesn't make it the same thing. > Nothing defined > implementation of the passage of a function settings. But it turns out that > in the case of gcc, they are pushed onto the stack from right to left. I think it depends on the hardware architecture. > As it > has been since the dawn of time in Savannah, it is definitely impossible to > change this state of affairs in gnou. Thus be it! > > So my question is: reverse the order of parameters (shock me, but) make > functional! What about you? Portability? I don't understand the question.