30

Ok j'y ai reflechi hier soir. J'avais tord. Vous aviez raison. GCC est ok avec la norme. Mais je persiste a penser que ce sont des warnings a la con tongue

31

On m'a conseille de soumettre un DR pour modifier la norme cheeky

http://www.open-std.org/jtc1/sc22/wg14/www/docs/summary.htm

32

Nouveau jeu:
Trouvez et expliquez LE warning:

struct toto {int x;};
typedef struct toto tutu[1];

int g() {
 tutu a;
 tutu *b = &a;
 return 0;
}

int h (tutu a) {
  tutu *b = &a;
  return 0;
}

33

Warning avec GCC et ICC cheeky

34

c'est louche hum

ca me met d'ailleurs dans le flou a propos des tableaux, je sais plus comment ca se passe :
typedef int Tab[20];
typedef struct {
 Tab t;
} St;

void f() {
  St s,s2;

  s=s2; //ca recopie tout le tableau ou juste les pointeurs ?
}

35

Tout le tableau. D'ailleurs le .s le confirme:

GCC 3.4:
h:
	subl	$172, %esp
	leal	80(%esp), %edx
	movl	%esp, %eax
	pushl	%ecx
	pushl	$80
	pushl	%eax
	pushl	%edx
	call	memcpy
	addl	$188, %esp
	ret


ICC 8.1
h:
..B1.1:                         # Preds ..B1.0
        subl      $160, %esp                                    #20.10
        movl      (%esp), %eax                                  #23.5
        movl      4(%esp), %edx                                 #23.5
        movl      8(%esp), %ecx                                 #23.5
        movl      %eax, 80(%esp)                                #23.5
        movl      12(%esp), %eax                                #23.5
        movl      %edx, 84(%esp)                                #23.5
        movl      %ecx, 88(%esp)                                #23.5
        movl      %eax, 92(%esp)                                #23.5
        movl      16(%esp), %eax                                #23.5
        movl      %eax, 96(%esp)                                #23.5
        movl      20(%esp), %eax                                #23.5
        movl      %eax, 100(%esp)                               #23.5
        movl      24(%esp), %eax                                #23.5
        movl      %eax, 104(%esp)                               #23.5
        movl      28(%esp), %eax                                #23.5
        movl      %eax, 108(%esp)                               #23.5
        movl      32(%esp), %eax                                #23.5
        movl      %eax, 112(%esp)                               #23.5
        movl      36(%esp), %eax                                #23.5
        movl      %eax, 116(%esp)                               #23.5
        movl      40(%esp), %eax                                #23.5
        movl      %eax, 120(%esp)                               #23.5
        movl      44(%esp), %eax                                #23.5
        movl      %eax, 124(%esp)                               #23.5
        movl      48(%esp), %eax                                #23.5
        movl      %eax, 128(%esp)                               #23.5
        movl      52(%esp), %eax                                #23.5
        movl      %eax, 132(%esp)                               #23.5
        movl      56(%esp), %eax                                #23.5
        movl      %eax, 136(%esp)                               #23.5
        movl      60(%esp), %eax                                #23.5
        movl      %eax, 140(%esp)                               #23.5
        movl      64(%esp), %eax                                #23.5
        movl      %eax, 144(%esp)                               #23.5
        movl      68(%esp), %eax                                #23.5
        movl      %eax, 148(%esp)                               #23.5
        movl      72(%esp), %eax                                #23.5
        movl      %eax, 152(%esp)                               #23.5
        movl      76(%esp), %eax                                #23.5
        movl      %eax, 156(%esp)                               #23.5
                                # LOE ebx ebp esi edi
..B1.2:                         # Preds ..B1.1
        addl      $160, %esp                                    #24.1
        ret                                                     #24.1


Tigcc, base sur GCC 4
h:
	rts


Oups pas pour tigcc wink

36

Au passage vous noterez la puissance du "pushl %ecx " de GCC qui ne sert qu'a... comserver l'alignement de la pile a 16 octets gni

37

PpHd :
Nouveau jeu:
Trouvez et expliquez LE warning:

struct toto {int x;};
typedef struct toto tutu[1];

int g() {
 tutu a;
 tutu *b = &a;
 return 0;
}

int h (tutu a) {
  tutu *b = &a;
  return 0;
}

ben ca c'est normal, une fonction n'a jamais vraiment un tableau en parametre, c'est converti automagiquement en pointeur... tu peux t'en convaincre en regardant sizeof(a) : dans le premier cas, c'est sizeof(struct toto)*1, dans l'autre c'est sizeof(struct toto*) smile

« The biggest civil liberty of all is not to be killed by a terrorist. » (Geoff Hoon, ministre des transports anglais)