From owner-freebsd-chat Tue Aug 8 17:45:37 2000 Delivered-To: freebsd-chat@freebsd.org Received: from mail.ptd.net (mail2.ha-net.ptd.net [207.44.96.66]) by hub.freebsd.org (Postfix) with SMTP id D12BB37B88B for ; Tue, 8 Aug 2000 17:45:26 -0700 (PDT) (envelope-from tms2@mail.ptd.net) Received: (qmail 11866 invoked from network); 9 Aug 2000 00:45:23 -0000 Received: from du215.cli.ptd.net (HELO mail.ptd.net) (204.186.33.215) by mail.ptd.net with SMTP; 9 Aug 2000 00:45:23 -0000 Message-ID: <39908B06.D1238928@mail.ptd.net> Date: Tue, 08 Aug 2000 18:34:46 -0400 From: "Thomas M. Sommers" Organization: None X-Mailer: Mozilla 4.72 [en] (X11; I; FreeBSD 4.0-RELEASE i386) X-Accept-Language: en MIME-Version: 1.0 To: Alfred Perlstein Cc: Mark Ovens , chat@FreeBSD.ORG Subject: Re: C time functions - problem References: <20000808201807.H250@parish> <20000808122832.I4854@fw.wintelcom.net> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-chat@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org Alfred Perlstein wrote: > > * Mark Ovens [000808 12:21] wrote: > > Can anyone tell me why the call to localtime() in the code below > > should segfault in tzset()? > > > > Running it in the debugger shows that ``t'' is set to a sensible > > value. > > > > Program received signal SIGSEGV, Segmentation fault. > > 0x280be4c8 in tzset () from /usr/lib/libc.so.4 > > > > > > #include > > #include > > > > int main() { > > struct tm *timeptr; > > char buf[BUFSIZ]; > > size_t size; > > time_t t; > > > > tzset; > > > > t = time((time_t *)0); > > timeptr = localtime((time_t *)t); > > > > ..... > > Please don't do disgusting things with casts. > > Do not cast a time_t to a time_t *, they aren't the same. > > Don't cast 0 to a pointer type, use NULL. Or just use 0. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-chat" in the body of the message