On Wed, Apr 04, 2007 at 07:50:02PM +0100, Stephen Gran wrote: > This one time, at band camp, Sven Luther said: > > > > The code yielding to this was of the kind of : > > > > struct tm tm; > > time_t t; > > t = time(NULL); > > localtime (&t, &tm); > > > > This is in a fr_FR.utf8 locale, on a powerpc box. The same code on an x86 > > box > > just segfaults without error message. > > That doesn't even compile here:
yeah, it's localtime_r i used. > #include <time.h> > #include <stdlib.h> > > int main (void) { > struct tm tm; > time_t t; > t = time(NULL); > localtime (&t, &tm); > exit(0); > } > > [EMAIL PROTECTED]:~$ gcc -Wall t.c > t.c: In function ‘main’: > t.c:8: error: too many arguments to function ‘localtime’ > [EMAIL PROTECTED]:~$ > > This code works fine, though: > > #include <time.h> > #include <stdlib.h> > > int main (void) { > struct tm *tm; > time_t t; > t = time(NULL); > tm = localtime (&t); > exit(0); > } > > [EMAIL PROTECTED]:~$ gcc -Wall t.c > [EMAIL PROTECTED]:~$ LC_ALL=fr_FR.utf8 ./a.out > [EMAIL PROTECTED]:~$ And indeed, like i said, it worked fine 100s of times, and then died. Try : int main (void) { struct tm tm; time_t t; while (1) { t = time(NULL); localtime_r (&t, &tm); } exit(0); } >