From owner-freebsd-questions@FreeBSD.ORG Tue Apr 11 23:13:11 2006 Return-Path: X-Original-To: freebsd-questions@freebsd.org Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id DD59D16A401 for ; Tue, 11 Apr 2006 23:13:11 +0000 (UTC) (envelope-from reitz@eecs.cwru.edu) Received: from beta.eecs.cwru.edu (beta.EECS.CWRU.Edu [129.22.150.110]) by mx1.FreeBSD.org (Postfix) with ESMTP id 6C24E43D45 for ; Tue, 11 Apr 2006 23:13:11 +0000 (GMT) (envelope-from reitz@eecs.cwru.edu) Received: from bender ([::ffff:129.22.151.243]) (TLS: TLSv1/SSLv3,168bits,DES-CBC3-SHA) by beta.eecs.cwru.edu with esmtp; Tue, 11 Apr 2006 19:13:10 -0400 id 000ABE84.443C3806.00005CD4 Date: Tue, 11 Apr 2006 19:12:50 -0400 (EDT) From: Andy Reitz X-X-Sender: reitz@bender To: Jonathan Herriott In-Reply-To: <6a56d69c0604111607l5fba5939pfc6461a99a2ceab3@mail.gmail.com> Message-ID: References: <6a56d69c0604111554o587ce2c5ha1ff4ea20bbab0a4@mail.gmail.com> <200604111857.43171.nb_root@videotron.ca> <6a56d69c0604111607l5fba5939pfc6461a99a2ceab3@mail.gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Cc: freebsd-questions@freebsd.org, Nicolas Blais Subject: Re: pow function working unexpectedly 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: Tue, 11 Apr 2006 23:13:11 -0000 On Tue, 11 Apr 2006, Jonathan Herriott wrote: > Question then. Why would it work when I don't use variables if I > don't include the library? This question is just out of curiosity. That's a pretty good question. In the case where we have pow(x,y), I see this: areitz@bottom[~/src]$ gcc -c pow_test.c areitz@bottom[~/src]$ nm pow_test.o 00000000 T main U pow U printf In the case where it is pow(2,3), I see this: areitz@bottom[~/src]$ gcc -c pow_test.c areitz@bottom[~/src]$ nm pow_test.o 00000000 T main U printf So, clearly, something is optimizing the pow() function away when the arguments are hard-coded lvalues, instead of varibles. Now, what that thing *is*, I don't know. -Andy.