I'm trying to free a pointer to a volatile buffer (the pointer is not volatile [I think...])
void try_this(volatile int* vint)
{
free(vint);
}
gives me:
warning: passing argument 1 of 'free' discards qualifiers from pointer target type
This seems to offer an explanation that would be valid for freeing: int * volatile vint
http://lists.freebsd.org/pipermail/freebsd-hackers/2005-January/009652.html
It seems to suggest that because the pointer could be pointing to invalid memory (because it is volatile it could have changed outside the normal flow of the program/thread) and this is why the behavior is discouraged, but... The pointer in this case (as far as I am aware) is not volatile, its the data thats pointed to thats volatile, surely free shouldn't care if this changes?
Can anyone offer a better explanation? (or reason why im totally wrong!)