I'm aware of this SO question and this SO question. The element of novelty in this one is in its focus on Xcode, and in its use of square brackets to dereference a pointer to void.
The following program compiles with no warning in Xcode 4.5.2, compiles with a warning on GCC 4.2 and, even though I don't have Visual Studio right now, I remember that it would consider this a compiler error, and MSDN and Internet agree.
#include <stdio.h>
int main(int argc, const char * argv[])
{
int x = 24;
void *xPtr = &x;
int *xPtr2 = (int *)&xPtr[1];
printf("%p %p\n", xPtr, xPtr2);
}
If I change the third line of the body of main to:
int *xPtr2 = (int *)(xPtr + 1);
It compiles with no warnings on both GCC and Xcode.
I would like to know how can I turn this silence into warnings or errors, on GDB and especially Xcode/LLVM, including the fact that function main is int but does not explicitly return any value (By the way I think -Wall does the trick on GDB).