From owner-freebsd-current Mon Nov 11 10: 8: 6 2002 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 991B437B401 for ; Mon, 11 Nov 2002 10:08:04 -0800 (PST) Received: from dignus.com (sdsl-64-32-254-102.dsl.iad.megapath.net [64.32.254.102]) by mx1.FreeBSD.org (Postfix) with ESMTP id C504D43E77 for ; Mon, 11 Nov 2002 10:08:03 -0800 (PST) (envelope-from rivers@dignus.com) Received: from lakes.dignus.com (lakes.dignus.com [10.0.0.3]) by dignus.com (8.11.6/8.11.3) with ESMTP id gABHu8R16669; Mon, 11 Nov 2002 12:56:08 -0500 (EST) (envelope-from rivers@dignus.com) Received: (from rivers@localhost) by lakes.dignus.com (8.11.6/8.11.3) id gABI2jX55939; Mon, 11 Nov 2002 13:02:45 -0500 (EST) (envelope-from rivers) Date: Mon, 11 Nov 2002 13:02:45 -0500 (EST) From: Thomas David Rivers Message-Id: <200211111802.gABI2jX55939@lakes.dignus.com> To: brandt@fokus.gmd.de, rivers@dignus.com Subject: Re: gcc 3.2.1 optimization bug ? Cc: FreeBSD-current@FreeBSD.ORG, gallatin@cs.duke.edu In-Reply-To: <20021111172959.W32091-100000@beagle.fokus.gmd.de> Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Harti Brandt wrote: > > > Hmm, I though the following would work: > > void > foo(unsigned short *s) > { > unsigned short temp; > > temp = s[0]; > s[0] = s[1]; > s[1] = temp; > } > > main() > { > int i = 0x12345678; > > foo(&i); > printf("%08x\n", i); > } > > because how would the compiler in main() know, that you do something wrong > in foo(). But... if you compile this with -O5, it does not work! This is > because the compiler inlines foo() into main and the program prints junk like > 0x12342804. Nope - that doesn't work either. The call to foo() is not compatible with the prototype (in fact, the Systems/C compiler issues a warning on this: Warning #2034: passing argument 1 from incompatible pointer type I believe gcc would as well. - Dave Rivers - -- rivers@dignus.com Work: (919) 676-0847 Get your mainframe programming tools at http://www.dignus.com To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message