Public bug reported:

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)

** Affects: eglibc (Ubuntu)
     Importance: Undecided
         Status: New


** Tags: amd64 apport-bug oneiric

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/898759

Title:
  math.h functions not recognized when taken with variables as arguments

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/eglibc/+bug/898759/+subscriptions

-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to