I am using a shared memory for storing some data using the shmget function. Then I use shmat to attach it and save data. The next time i attach it, the program crashes. What are the possibilities that this line:
if((smemPtr = (int*)shmat(sMemId,NULL,0)) != (int *) -1)
crashes? I need to know the scenarios under which this line crashes. The sMemId has a value.
Pointer to another object is unsigned value. In this code i see C-style casting signed (negative) value to unsigned. Result is depend from compiler, platform, and in the general case — undefined.