If there is a function does not take any references or pointers as parameters, its return type is unused, and it makes no calls that observably leave the system (I/O calls, change system time, etc), is it guaranteed to modify only the class in which it is defined (or nothing at all)?
The only exceptions that I can think of to this rule is something like the following:
void a(int b, int c){
*((int*)b) = c; }
int main() {
int d=1;
a((int)(&d),d+1);
return 0; }
Is that guaranteed to be defined? I know that int*
and int
do not have to be the same size, but if they are defined to be the same size, does this have to work, or is it still undefined behavior?
The goal is to see if a function can be legally optimized out (i.e. if you can prove that it has no side effects, it can be removed).