I have a function in which one of the function arguments is an integer. During function invocation I am passing an enumerated datatype to this function. After building using gcc, any access to the INTEGER variable inside the function causes a segmentation fault.
Sample code:
void somefun (unsigned int nState) { switch (nState) // <-- Crashes on this line { // // functionality here ... // } } enum { UNDEFINED = -1, STATE_NICE, STATE_GREEDY } E_STATE; int main (int argc, char *argv []) { somefun (STATE_NICE); }
From all your answers it seems that the code is logically correct, and I need to investigate the real reason for the crash. I will investigate it and post it soon.