Strange localtime/gmtime behaviour

Peter Teichmann teich-p at Rcs1.urz.tu-dresden.de
Sun Apr 29 17:39:11 BST 2001


Am Sonntag, 29. April 2001 11:59 schrieb Peter Naulls:
> (b) produced a minimal text case which exhibits the problem.
>
> I would think it very odd that a date handling problem alone could do
> more than simply crash the running program.

Here is the testcase:

---file timetest.cpp start
#include <stdio.h>
#include <time.h>
 
void main(void)
{
  time_t t;
  struct tm *tt;
 
  t=time(0);
  tt=localtime(&t);
  printf("%d %08x\n", t, tt);
}
--file timetest.cpp end

just compile it without any additional switches and the actual gccsdk. 
Transfer the program to your RiscOS machine (mine is a SA RiscPC with RO4) 
Disable DST using !Alarm. The program runs as expected. Enable DST again. The 
program stops before executing printf().

Replace localtime() with gmtime(). With DST disabled all is ok, but if you 
now enable DST the computer freezes completely.


Peter Teichmann



More information about the gcc mailing list