Please look at following sample code. FuncA runs forever during object lifetime due to while(1). Let's say code hits "CondB" for quite very long time ( 24 hours) or more. which means "curr_status" in funcB will not change during that time. Is it possible that optimization can kick in and never checks for updated value of "curr_status" after that ? Should I use volatile here?
void funcB(string curr_status){
static string prev_status = "123";
if(prev_status != curr_status){
//do sometthing
prev_status = curr_status;
}
}
void funcA(){
while(1){
if(condA)
funcB("123");
if(condB)
funcB("xyz");
}
}