www.gnu.org/software/gcc/bugs/#nonbugs_c (with ++ / --)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



    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 (?). 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. 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?

    Thank you for the attention you have brought to this email.
Patrick Serru


    J'ai un probléme philosophique avec le compilateur gcc. À l'école, il me 
semble avoir appris, que les expression étaient évaluée de gauche à droite 
quand elles sont séparées par une virgule. Je ne comprends donc pas pourquoi 
ceci n'est pas appliqué quand il s'agit du passage de paramètres à une 
fonction. Donc, je constate que si j'écris:
void truc (int a, int b, int c);
puis:
truc(a, b, a+=1);
le 1er et le 3ème argument ont la même valeur.

    Vous direz peut-être: l'ordre dont on vous a parlé à l'école concerne une 
expression, ce que n'est pas une suite de paramètres (?). Rien ne défini  
l'implémentation le passage des paramètres d'une fonction. Or, il se trouve 
que dans le cas de gcc, ils sont poussés dans la pile de droite à gauche. 
Comme il en est ainsi depuis la nuit des temps dans la savane, il est 
définitivement impossible de changer cet état de fait chez gnou. 
Ainsi-soit-il!

    Alors, ma question est: inverser l'ordre des paramètres (me choquerait, 
mais) rendrait fonctionnel ! Qu'en pensez-vous ? Portabilité ?

    Merci pour l'attention que vous aurez porté à ce mail.
Patrick Serru




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux