From owner-freebsd-current@FreeBSD.ORG Wed Mar 31 02:20:41 2004 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 2D63A16A4CE for ; Wed, 31 Mar 2004 02:20:41 -0800 (PST) Received: from critter.freebsd.dk (critter.freebsd.dk [212.242.86.163]) by mx1.FreeBSD.org (Postfix) with ESMTP id 6063643D3F for ; Wed, 31 Mar 2004 02:20:38 -0800 (PST) (envelope-from phk@phk.freebsd.dk) Received: from critter.freebsd.dk (localhost [127.0.0.1]) by critter.freebsd.dk (8.12.11/8.12.11) with ESMTP id i2VAKZbe009533; Wed, 31 Mar 2004 12:20:35 +0200 (CEST) (envelope-from phk@phk.freebsd.dk) To: Rene Ladan From: "Poul-Henning Kamp" In-Reply-To: Your message of "Wed, 31 Mar 2004 12:18:34 +0200." <20040331101834.GA21652@dyn-099164.nbw.tue.nl> Date: Wed, 31 Mar 2004 12:20:35 +0200 Message-ID: <9532.1080728435@critter.freebsd.dk> cc: freebsd-current@freebsd.org Subject: Re: system's gcc bug? X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 31 Mar 2004 10:20:41 -0000 In message <20040331101834.GA21652@dyn-099164.nbw.tue.nl>, Rene Ladan writes: > >--rwEMma7ioTxnRzrJ >Content-Type: text/plain; charset=us-ascii >Content-Disposition: inline > >Hi, > >I'm getting runtime errors when executing the following program and >declaring one of the arrays: > >---------------- > >#include > >int main(void) { >/* int a[4] = { 0, 1, 2, 3 }; enable this line to get a buserror */ > int *i; >/* int b[4] = { 0, 1, 2, 3 }; enable this line to get a segfault */ > for (*i = 0; *i < 4; (*i)++) > printf("%p %i\n", i, *i); > return(0); > } You have allocated no storage backing for *i, so your for loop writes the integers 0...3 to a random place in memory. -- Poul-Henning Kamp | UNIX since Zilog Zeus 3.20 phk@FreeBSD.ORG | TCP/IP since RFC 956 FreeBSD committer | BSD since 4.3-tahoe Never attribute to malice what can adequately be explained by incompetence.