Code:
#include <stdio.h>

static void DoSwapPointer(void** pointer1, void** pointer2)
{
    void* tempPointer1 = *pointer1;
    void* tempPointer2 = *pointer2;
    *pointer1 = tempPointer2;
    *pointer2 = tempPointer1;
    return;
}

int main()
{
    int data1 = 15, data2 = 30;
    int* ptr1 = &data1;
    int* ptr2 = &data2;

    printf("DBGA %d %d\n", *ptr1, *ptr2);
    DoSwapPointer((void**)&ptr1, (void**)&ptr2);
    printf("DBGB %d %d\n", *ptr2, *ptr2);
    return 0;
}
I compile these code with "gcc main.c". The result is
Code:
DBGA 15 30
DBGB 30 15
But if I compile them with "gcc -O3 main.c". I will get
Code:
DBGA 15 30
DBGB 15 30
Isn't it strange? Why would this happen?