is it safe having a function like:
and pass a pointer to the same object as both arguments?Code:void func(void *out_p, const void *in_p);
since the object passed as the arguments is both - const and non-const.
so might optimization produce wrong code in that case - or are arguments skipped by optimization anyway?
example:
.) read from *in_p
.) modify *out_p - thus the object pointed to by in_p has changed.
read from *in_p again. since the object pointed to by in_p was declared const, the compiler might think it has not changed and do some optimization. so instead of reading the changed version, the original version would be read.