I just want to make sure I'm not being stupid before I send in a bug.
The problem seems to be with gcc when using the pow function in the
math.h library. Here's code that works:
#include
#include
int main()
{
printf("%f\n", pow(2,3));
return 0;
}
Now, the following will not compil
On Tuesday 11 April 2006 18:54, Jonathan Herriott wrote:
> I just want to make sure I'm not being stupid before I send in a bug.
> The problem seems to be with gcc when using the pow function in the
> math.h library. Here's code that works:
>
> #include
> #include
>
> int main()
> {
> print
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.
On 4/11/06, Nicolas Blais <[EMAIL PROTECTED]> wrote:
> On Tuesday 11 April 2006 18:54, Jonathan Herriott wrote:
> > I just want to make sure I'm not being stupid b
On Tuesday 11 April 2006 19:07, 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.
>
> On 4/11/06, Nicolas Blais <[EMAIL PROTECTED]> wrote:
> > On Tuesday 11 April 2006 18:54, Jonathan He
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:
[EMAIL PROTECTED]/src]$ gcc -c po
On Tue, Apr 11, 2006 at 11:07:35PM +, 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.
Because the compiler recognizes that pow() when called with only
constants as arguments can
Andy Reitz wrote:
> 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.
The C compiler precomputes constant expressions; your "pow(2,3)" is
being rewritten to "8" by the compile
On 4/12/06, Jonathan Herriott <[EMAIL PROTECTED]> 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.
Since you use only hard coded operands, the result is given, and gcc
optimizes such arithmetics and fun
With reference to my first example given is what I was talking about.
The first example properly ran with just compiling with:
gcc test.c
Here's the first example again:
> > > > #include
> > > > #include
> > > >
> > > > int main()
> > > > {
> > > > printf("%f\n", pow(2,3));
> > > > r
On Tuesday 11 April 2006 19:24, Colin Percival wrote:
> Andy Reitz wrote:
> > 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.
>
> The C compiler precomputes constant exp
Yes, thank you. I wasn't going to report it as a bug after you
pointed out my blatant mistake. Thanks again for the info.
Jon
On 4/11/06, Nicolas Blais <[EMAIL PROTECTED]> wrote:
> On Tuesday 11 April 2006 19:24, Colin Percival wrote:
> > Andy Reitz wrote:
> > > So, clearly, something is optimi
On 2006-04-11 22:54, Jonathan Herriott <[EMAIL PROTECTED]> wrote:
> I just want to make sure I'm not being stupid before I send in a bug.
> The problem seems to be with gcc when using the pow function in the
> math.h library. Here's code that works:
>
> #include
> #include
>
> int main()
> {
>
12 matches
Mail list logo