It basically states that passing a struct variable (declared in main(){}) as reference in the pthread_create() fn, is unsafe as the memory location of the variable (t in this case) may change.
Why is that so?
I thought global variable's location on the memory are -for all practical purposes- fixed throughout the execution.
It basically states that passing a struct variable (declared in main(){}) as reference in the pthread_create() fn, is unsafe as the memory location of the variable (t in this case) may change.
The memory location does not change, nor does the comment say that.
The value of the variable changes, not its address. What's more, passing a local variable such as this could cause it to go out of scope while some thread is still trying to access it.