Mod'ing struct tm causes segmentation fault on RHEL 5.4

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The following program generates a segmentation fault on RHEL 5.4. Other systems (eg: Solaris, AIX, RHEL 4) do not exhibit this problem.

Comments?

Tim

% cc -DBUG -o fault fault.c

=> fault.c <=
#include <stdio.h>
#include <time.h>
#include <sys/time.h>

main ()
{
 struct tm *date;
 int date_as_int;

date_as_int = time ((time_t *) NULL);
 date = localtime ((time_t *) &date_as_int);

#ifdef BUG
 date->tm_year %= 100;
#else
 while (date->tm_year >= 100)
   date->tm_year -= 100;
#endif

 printf ("%02d/%02d/%02d %02d:%02d:%02d\n",
     date->tm_year, date->tm_mon+1, date->tm_mday,
     date->tm_hour, date->tm_min, date->tm_sec);
}

Tim

--
redhat-list mailing list
unsubscribe mailto:redhat-list-request@xxxxxxxxxx?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/redhat-list


[Index of Archives]     [CentOS]     [Kernel Development]     [PAM]     [Fedora Users]     [Red Hat Development]     [Big List of Linux Books]     [Linux Admin]     [Gimp]     [Asterisk PBX]     [Yosemite News]     [Red Hat Crash Utility]


  Powered by Linux