From owner-freebsd-questions@FreeBSD.ORG Fri Mar 14 22:17:26 2008 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 165531065670 for ; Fri, 14 Mar 2008 22:17:26 +0000 (UTC) (envelope-from derek@computinginnovations.com) Received: from betty.computinginnovations.com (mail.computinginnovations.com [64.81.227.250]) by mx1.freebsd.org (Postfix) with ESMTP id A4C9E8FC17 for ; Fri, 14 Mar 2008 22:17:25 +0000 (UTC) (envelope-from derek@computinginnovations.com) Received: from p28.computinginnovations.com (dhcp-10-20-30-100.computinginnovations.com [10.20.30.100]) (authenticated bits=0) by betty.computinginnovations.com (8.14.2/8.13.8) with ESMTP id m2EMGnls003704; Fri, 14 Mar 2008 17:16:50 -0500 (CDT) (envelope-from derek@computinginnovations.com) Message-Id: <6.0.0.22.2.20080314171533.023f7c88@mail.computinginnovations.com> X-Sender: derek@mail.computinginnovations.com X-Mailer: QUALCOMM Windows Eudora Version 6.0.0.22 Date: Fri, 14 Mar 2008 17:16:39 -0500 To: Doug Hardie , freebsd-questions From: Derek Ragona In-Reply-To: References: Mime-Version: 1.0 X-Antivirus: avast! (VPS 080314-0, 03/14/2008), Outbound message X-Antivirus-Status: Clean X-ComputingInnovations-MailScanner-Information: Please contact the ISP for more information X-ComputingInnovations-MailScanner: Found to be clean X-ComputingInnovations-MailScanner-From: derek@computinginnovations.com X-Spam-Status: No Content-Type: text/plain; charset="us-ascii"; format=flowed X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Cc: Subject: Re: C compiler issue perhaps? X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Mar 2008 22:17:26 -0000 At 05:10 PM 3/14/2008, Doug Hardie wrote: >I have a program I was testing with gdb. I was trying to figure out >why c.rmonths was always zero when it should have been 6. Stepped >through using the gdb n command. Here is the output: > >(gdb) >215 c.rmonths = (edate - tdate) / toMONTHS; >(gdb) >223 c.dial_in = u.dial_in[0]; >(gdb) >224 c.dsl = u.dsl[0]; >(gdb) p c.rmonths >$1 = 0 >(gdb) p c >$2 = {fa = 0, pwp = 0, disp_email = 0, imonths = 0, rmonths = 6, > type = 73 'I', cd = 0 '\0', dial_in = 82 'R', dsl = 0 '\0', > dsl_kit = 0 '\0', ip = 0 '\0', domain = 0 '\0', n_domain = 0 '\0', > renewal = 89 'Y', program = "I\000\000"} >(gdb) p c->rmonths >$3 = 6 >(gdb) p c.rmonths >$4 = 6 > > >Notice, the first time i print it its zero. The second time its 6. >What gives here? I have seen this before but couldn't pin it down. >The program is not compiled with any optimization. It is in a shared >library though. It is hard to tell without the code you used. I would put some printf's in the code and see what and when that variable gets set to in actual running code. -Derek -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean.