hi, I'm actually writing a program in C and i'm fighting with an address dereferencing since some days now.
The program run on a non *n*x system and I can't produce the error on my linux system so i can only describe it... sorry. In my system depending if i (un)comment the commented lines in the next code, the 1st or the 2nd string is printed. uncommented -> pointers are the same commented -> pointers aren't the same I'm compiling with (to run on my VM): -std=gnu99 -Wall -Werror -nostdinc -Wstrict-aliasing=2 -fno-builtin -I../include -I../ and (on linux): -std=gnu99 -Wall -Werror -Wstrict-aliasing=2 ggc version : gcc (GCC) 3.4.6 GNU assembler 2.16.1 the linkage is a bit different too as my binary is neither ELF nor a.out ... The asm inline part was a way to escape the problem as the compiled asm wasn't working... But after that "patch" an incrementation of "ap" : ap++; after the assignation wasn't working and in the asm code the increment wasn't on the good (register+offset)/address so ... the code : int the_bug(const char *fmt, ...) { char **ap; char **s = (char **)(&fmt); /* __asm__ volatile ( */ /* "\tleal %1, %%eax\n" */ /* "\tmovl %%eax,%0\n" */ /* "\tmovl %1, %%eax\n" */ /* "\tmovl %2, %%ebx \n" */ /* "\tmovl %%eax, (%%ebx)\n" */ /* : "=m"(ap) : "m" (fmt), "m"(ap)); */ if (*s == (char *)fmt) write(1, "they are the same\n", 18); else write(1, "they aren't the same\n", 21); return (0); } the ASM generated (uncommented and commented) (as shown in biew (->objdump doesn't work because of the "not ELF format")) : push bp | push bp mov bp, sp | mov bp, sp sub (w) sp, +08 | sub (w) sp, +08 lea ax, [di+08] | lea ax, [di+08] mov [di-08], ax | mov [di-08], ax lea ax, [di+08] | mov [di-04], ax | mov ax, [di+08] | mov bx, [di-04] | mov [bp+di], ax | mov ax, [di-08] | mov ax, [di-08] mov ax, [bx+si] | mov ax, [bx+si] cmp ax, [di+08] | cmp ax, [di+08] jne file:000029B4 DIFF | jne file:000029A6 sub (w) sp, +04 | sub (w) sp, +04 push (w) +0D | push (w) +0D push (w) 3AA8 | push (w) 3AA8 add [bx+si], al | add [bx+si], al push (w) 01 | push (w) 01 calln file:0000295D | calln file:0000295D ??? (w) di | ??? (w) di add (w) sp, +10 | add (w) sp, +10 jmps file:000029C8 DIFF | jmps file:000029BA sub (w) sp, +04 | sub (w) sp, +04 push (w) +10 | push (w) +10 push (w) 3AB6 | push (w) 3AB6 add [bx+si], al | add [bx+si], al push (w) 01 | push (w) 01 calln file:0000295D | calln file:0000295D ??? (w) di | ??? (w) di add (w) sp, +10 | add (w) sp, +10 mov ax, 0000 | mov ax, 0000 add [bx+si], al | add [bx+si], al leave | leave retn | retn If anyone has an idea... to reproduce the error, ..... or (better :)) correct it... -- Thibaud