From: Moritz J. <mo...@jo...> - 2006-11-03 10:39:27
|
Hi all, I ran across some code, which falsely generates a warning using CIL. The following code snippet demonstrates it: 1 #include <stdio.h> 2 #include <stdlib.h> 3 4 int main(void) { 5 char *p; 6 int i; 7 8 p = malloc(2*sizeof(int)); 9 *(int *)p = 1; 10 *((int *)p + 1) = 2; 11 12 i = *((int *)p)++; 13 printf("%d\n", i); 14 i = *((int *)p)++; 15 printf("%d\n", i); 16 17 return 0; 18 } Line 12 and 14 are transformed to: ... #line 12 tmp = (int *)p; #line 12 p = (int *)p + 1; #line 12 i = *tmp; ... GCC justifiably generates a warning for the "p = (int *)p + 1" construct. CIL should probably add the missing cast to (char *), so that it transforms to the following construct: p = (char *)((int *)p + 1) What do you think? Moritz |