Serial.print makes variable change value

Hello everyone,

I have a little issue which i cannot solve on my own.
I'm currently working on an I2C-communication between two arduinos (1Mega, 1 Uno).

If I print the sent values from the slave, I can see the correct data in the Serial print. (see code below).
The displayed value will then correctly be returned (print of returned value in other function).

HOWEVER:
When i delete the Serial print, which I marked with the comment, the function will return 255.

How can a serial print influence the actual data of my variables??

The content of the print message does not even matter. Serial.println("This sucks");has the same effect....

Any ideas?

Thanks in advance and best regards,

BoredEngineer

[...]  //some other stuff

delay(1000);  //waiting for an I2C message to be recieved

Serial.println(ii2c_sent_data_value);   //THIS!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

if(ii2c_sent_data_type != 0){
 if(ii2c_sent_data_type == idata_type && ii2c_sent_plant_id == igoal_plant_id){   
  return ii2c_sent_data_value;
 }
}
return 255;

Some other stuff... because.

EvenMoreBoredEngineer

Not enough info here to tell. Need to see your entire sketch.