Hello Pelle,
I don't know if it can be considered as a bug but here is what I have found:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(void) {
int i;
char s[10];
strcpy(s, "TEST");
for (i = 0; i < 2; i++) {
char c1, c2, r1, r2;
c1 = s[0]; c2 = s[1];
r1 = 0; r2 = 0;
_asm {
PUSHAD
MOV AL, BYTE PTR [c1]
MOV CL, BYTE PTR [c2]
MOV BYTE PTR [r1], AL
MOV BYTE PTR [r2], CL
POPAD
}
printf("r1 : %c --- r2 : %c\n", r1, r2);
}
system("PAUSE");
return 0;
}
In this small example, the content of r1 and r2 variables is incorrect if optimizations compiler option is Maximize speed.
Build warning :
Building main.obj.
D:\Test\main.c(11): warning #2115: Local 'c1' is initialized but never used.
D:\Test\main.c(11): warning #2115: Local 'c2' is initialized but never used.
Building Test.exe.
Done.
There is no problem if I add c1 and c2 variables in the printf function or if I remove compiler optimization.
Is it normal?
For information, I have done the same test with Visual C++ 2005 and there is no problem.