Hello!
I encountered a possible interesting issue while programming with C::B 10.05 in Windows 7.
I was testing a program that somewhere deep inside apparently was changing the local time.
I have recreated the issue with this small example program:
#include <windows.h>
int main()
{
//get the time
SYSTEMTIME st;
GetLocalTime(&st);
//put it 1 hour in the past ( I know this is not the right way to do it but let's make an
//assumption that this won't change the day for the purpose of the test)
st.wHour -=1;
//btw in my system Avira thinks this contains a trojan called cuckold.A . Please for the purposes of this test disable avira.
SetLocalTime(&st);
return 0;
}
The program I was testing was not raising any flags, but this little 4 lines example program actually raised a flag in Avira Anti-Virus and got stopped. If this happens to you disable it just for the test here. You can see the code, nothing malicious happens except for going 1 hour in the past.
After compiling and running this from inside codeblocks it works fine and does indeed change the time to 1 hour in the past. But as a result you can see that the execution of the program took negative minutes and seconds.
The interesting thing happens if you attempt to make any changes on this program and run again. You may think that the newly changed program will run but it will not. If you press compile and run it will not compile but it will just run this previous program that changed the hour, and go yet 1 more hour to the past. Took me sometime to realize what was happening since I was debugging at the time and the program was stepping into totally different functions than the code was saying.
I have not had the pleasure to look into C::B code but I suppose that it must getting really confused by things being in the past, so any changes you make to a source file are not detected as changes and nothing new is compiled, so the old program runs again.
The reason I made this post is to ask if anyone else has come upon this interesting issue. I can't think of any way to fix this so I don't have any suggestions but I just wanted to know if people here are aware of the potential of this happening.
I suppose the only solution would be to just make sure running a program from inside C::B does not put the date in the past.