The warning probably occurs on "r=buffer+12" - this is invalid because r is an int* and buffer is a char*. The reason this is a problem that may need pointing out is that buffer+12 may not do what you want; either it will evaluate to &buffer[12] which is (void*)(&buffer[0]+12), or it will evaluate to &buffer+12*sizeof(int) which is (void*)(&buffer[0]+12*sizeof int), depending on whether the compiler converts buffer to an int* before adding 12, or converts buffer+12 to an int*.

Basically when you use a pointer to a bunch of objects, the compiler assumes that (pointer+1) means the next object, not literally the address of the object the pointer is currently pointing to plus 1. So int *p=1000; p++; will increase p to 1004 if sizeof int=4; struct s { ... } *p=1000; p++; will increase p by sizeof struct s. And char *p=1000; p++; will increase p to 1001.

So by assigning a char* pointer to an int* you're immediately creating an ambiguity. Is buffer1 to be treated as an int* or a char*, and does +12 mean +12*sizeof char or +12*sizeof int? A cast will get rid of the problem, e.g. r = (int*)buffer +12; or r=(int*)(&buffer[12]);

The program prints x=1 because that's what you're telling it to do. int x=0; x=1; printf("x=%d\n",x); will print x=1. You don't need a debugger to tell you that, just RTFC. To modify the program to print "x=0" just remove "x=1;".

I think "where" is the command for printing a stack in gdb, but of course you need a core dump. Probably what you need is to step through the code rather than to get a stack. I tend to use Visual Studio so have limited experience with gdb.