tanf causes FPE

Bug #65998 reported by Juanjo Garcia-Ripoll
2
Affects Status Importance Assigned to Milestone
glibc (Ubuntu)
Confirmed
Medium
Unassigned

Bug Description

Binary package hint: libc6-amd64

When one sets the floating point environment to trap exceptions and uses tanf with a value that should not produce singularities, an exception is sometimes signalled.

To reproduce: store the following piece of code in a file foo.c and build using gcc -o foo foo.c -lm When you execute the program, it will give rise to an exception

What should have happened: The program should have output the value 1

#define _GNU_SOURCE
#include <math.h>
#include <fenv.h>
#include <stdio.h>

int main()
{
  int bits = FE_UNDERFLOW;
  feenableexcept(bits);

  printf("%d", tanf((float)(M_PI/4)));

  return 0;
}

Revision history for this message
Matthias Klose (doko) wrote :

confirmed with glibc-2.5, amd64; works on i386

Changed in glibc:
importance: Undecided → Medium
status: Unconfirmed → Confirmed
Revision history for this message
Juanjo Garcia-Ripoll (worm) wrote :

2006-10-13 and we are at 2008-08-03. Seriously, is this such a difficult bug?

Revision history for this message
Matthias Klose (doko) wrote :

> 2006-10-13 and we are at 2008-08-03. Seriously, is this such a difficult bug?

no. care to recheck with 8.04 and 8.10 (development)?

Changed in glibc:
status: Confirmed → Incomplete
Revision history for this message
Daniel T Chen (crimsun) wrote :

Using 4:4.2.3-1ubuntu6 (hardy-proposed) on amd64, I receive an FPE.

Using 4:4.3.1-1ubuntu2 (intrepid chroot) on amd64, I receive 85028072.

Changed in glibc:
status: Incomplete → Confirmed
Revision history for this message
Daniel T Chen (crimsun) wrote :

To clarify the previous comment, for hardy-proposed:

gcc-4.2:
  Installed: 4.2.4-1ubuntu1
  Candidate: 4.2.4-1ubuntu1
  Version table:
 *** 4.2.4-1ubuntu1 0
        500 http://us.archive.ubuntu.com hardy-proposed/main Packages
        100 /var/lib/dpkg/status
     4.2.3-2ubuntu7 0
        500 http://us.archive.ubuntu.com hardy/main Packages

Using built-in specs.
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --enable-languages=c,c++,fortran,objc,obj-c++,treelang --prefix=/usr --enable-shared --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --enable-nls --with-gxx-include-dir=/usr/include/c++/4.2 --program-suffix=-4.2 --enable-clocale=gnu --enable-libstdcxx-debug --enable-objc-gc --enable-mpfr --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.2.4 (Ubuntu 4.2.4-1ubuntu1)

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.