Date: Tue, 11 Apr 2006 19:12:50 -0400 (EDT) From: Andy Reitz <reitz@eecs.cwru.edu> To: Jonathan Herriott <herriojr@gmail.com> Cc: freebsd-questions@freebsd.org, Nicolas Blais <nb_root@videotron.ca> Subject: Re: pow function working unexpectedly Message-ID: <Pine.SOL.4.53.0604111911260.3684@bender> In-Reply-To: <6a56d69c0604111607l5fba5939pfc6461a99a2ceab3@mail.gmail.com> References: <6a56d69c0604111554o587ce2c5ha1ff4ea20bbab0a4@mail.gmail.com> <200604111857.43171.nb_root@videotron.ca> <6a56d69c0604111607l5fba5939pfc6461a99a2ceab3@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
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.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.SOL.4.53.0604111911260.3684>
