From owner-freebsd-hackers@FreeBSD.ORG Thu Aug 7 17:02:36 2008 Return-Path: Delivered-To: hackers@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 159DE1065679; Thu, 7 Aug 2008 17:02:36 +0000 (UTC) (envelope-from jdc@parodius.com) Received: from mx01.sc1.parodius.com (mx01.sc1.parodius.com [72.20.106.3]) by mx1.freebsd.org (Postfix) with ESMTP id F41FA8FC14; Thu, 7 Aug 2008 17:02:35 +0000 (UTC) (envelope-from jdc@parodius.com) Received: by mx01.sc1.parodius.com (Postfix, from userid 1000) id E06AF1CC0B3; Thu, 7 Aug 2008 10:02:35 -0700 (PDT) Date: Thu, 7 Aug 2008 10:02:35 -0700 From: Jeremy Chadwick To: "Sean C. Farley" Message-ID: <20080807170235.GA39461@eos.sc1.parodius.com> References: <489B0ACD.80008@kovesdan.org> <489B22BD.5050109@kovesdan.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.18 (2008-05-17) Cc: Gabor Kovesdan , fjoe@FreeBSD.org, hackers@FreeBSD.org Subject: Re: strange issue reading /dev/null X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 07 Aug 2008 17:02:36 -0000 On Thu, Aug 07, 2008 at 11:54:10AM -0500, Sean C. Farley wrote: > On Thu, 7 Aug 2008, Gabor Kovesdan wrote: > >> Sean C. Farley ha scritto: >>> You are testing c which has not been set. It works OK if you set c >>> then do the test: >>> >>> + c = fgetc(f); >>> if (c != EOF) >>> - printf("%c\n", fgetc(f)); >>> + printf("%c\n", c); >> Yes, you are right, this is what I meant, I'm just a bit >> disorganised.... >> Thanks! > > You are welcome. > > Actually, what I found odd was that the base gcc did not warn about > using an uninitialized variable using -Wall. Probably because you didn't use -O. -Wall includes -Wuninitialized, but -Wuninitialized only applies if you use optimisation. gcc won't bail if you use -Wall without -O, for obvious reasons. Case in point: $ gcc -Wall -o x x.c x.c: In function 'main': x.c:14: warning: control reaches end of non-void function $ gcc -Wuninitialized -o x x.c cc1: warning: -Wuninitialized is not supported without -O $ gcc -Wall -O -o x x.c x.c: In function 'main': x.c:14: warning: control reaches end of non-void function x.c:12: warning: 'c' is used uninitialized in this function gcc -- finding new ways every day to drive programmers crazy. :-) -- | Jeremy Chadwick jdc at parodius.com | | Parodius Networking http://www.parodius.com/ | | UNIX Systems Administrator Mountain View, CA, USA | | Making life hard for others since 1977. PGP: 4BD6C0CB |