[Bug 898759] Re: math.h functions not recognized when taken with variables as arguments
Jason Conti
898759 at bugs.launchpad.net
Thu Dec 1 19:44:14 UTC 2011
In oneiric you need to specify the libraries after the code due to
changes in http://wiki.debian.org/ToolChain/DSOLinking
gcc test.c -lm
GCC also has builtin versions of sqrt which are folded in when the value
of sqrt is a constant, so this is why you notice the differing behavior
between variable and constant values. With the constant version
compiling with:
gcc -fno-builtin -lm test.c
will give the same error.
** Changed in: eglibc (Ubuntu)
Status: New => Invalid
--
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to eglibc in Ubuntu.
https://bugs.launchpad.net/bugs/898759
Title:
math.h functions not recognized when taken with variables as arguments
Status in “eglibc” package in Ubuntu:
Invalid
Bug description:
When using gcc 4.6.1 to compile a program with functions from math.h,
the compiler does not recognize the functions and issues the following
error message:
undefined reference to `sqrt'
(with sqrt replaced by other functions when applicable) but only if
the functions are called with variables as their arguments.
The code below:
#include <stdio.h>
#include <math.h>
int main (){
long double x, y, z;
z = 2;
x = sqrt ((double) z);
y = sqrtl ((long double) z);
printf ("%.30Lg\n%.30Lg\n", (long double) x, (long double) y);
return 0;
}
triggers the bug when compiled with the command-line:
gcc -lm test.c
If I change the argument of the functions, so they read sqrt(2) or
sqrtl(2) the compiler does not complain and the program runs correctly
with the expected precision for each of the functions.
The bug also happens if the compiler is run with either -std=c99,
-std=gnu99 or -ansi in addition to the command-line above.
ProblemType: Bug
DistroRelease: Ubuntu 11.10
Package: libc6-dev 2.13-20ubuntu5
ProcVersionSignature: Ubuntu 3.0.0-13.22-generic 3.0.6
Uname: Linux 3.0.0-13-generic x86_64
ApportVersion: 1.23-0ubuntu4
Architecture: amd64
Date: Thu Dec 1 15:44:53 2011
InstallationMedia: Ubuntu 11.10 "Oneiric Ocelot" - Release amd64 (20111012)
ProcEnviron:
LANGUAGE=pt_BR:pt:en
PATH=(custom, no user)
LANG=pt_BR.UTF-8
SHELL=/bin/bash
SourcePackage: eglibc
UpgradeStatus: No upgrade log present (probably fresh install)
To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/eglibc/+bug/898759/+subscriptions
More information about the foundations-bugs
mailing list