This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/26927] New: math function log2 bug
- From: "bxin33 at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 29 Mar 2006 18:58:37 -0000
- Subject: [Bug c/26927] New: math function log2 bug
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
Most likely this bug was reported before; but I couldn't seem to find it in
this database. So, just in case. The bug is with gcc 3.3.5; I know 3.4.4 works
fine.
=========== test
#include <stdio.h>
#include <math.h>
int main() {
int g_size = 8;
int dim;
double dd;
dd = log2(g_size);
dim = (pow(2, (int)dd) >= g_size)?(int)dd : (int)dd + 1;
printf("log2(%d) = %.1f pow(2, (int)%d) >= %d = %d\n", g_size, dd,
(int)dd, g_size, (pow(2, (int)dd) >= g_size));
return 0;
}
============ compile & run
> gcc -v
Reading specs from /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.5/specs
Configured with:
/scratch/portage/tmp/portage/gcc-3.3.5-r1/work/gcc-3.3.5/configure
--enable-version-specific-runtime-libs --prefix=/usr
--bindir=/usr/i686-pc-linux-gnu/gcc-bin/3.3.5
--includedir=/usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.5/include
--datadir=/usr/share/gcc-data/i686-pc-linux-gnu/3.3.5
--mandir=/usr/share/gcc-data/i686-pc-linux-gnu/3.3.5/man
--infodir=/usr/share/gcc-data/i686-pc-linux-gnu/3.3.5/info
--with-gxx-include-dir=/usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.5/include/g++-v3
--host=i686-pc-linux-gnu --disable-altivec --disable-nls --enable-__cxa_atexit
--enable-clocale=gnu --with-system-zlib --disable-checking --disable-werror
--disable-libunwind-exceptions --enable-shared --enable-threads=posix
--enable-java-awt=gtk --enable-languages=c,c++,f77,java
Thread model: posix
gcc version 3.3.5 (Gentoo Linux 3.3.5-r1, ssp-3.3.2-3, pie-8.7.7.1)
> gcc -lm test_math.c
> ./a.out
log2(8) = 1075199136.0 pow(2, (int)1075199136) >= 8 = 1
--
Summary: math function log2 bug
Product: gcc
Version: 3.3.5
Status: UNCONFIRMED
Severity: minor
Priority: P3
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: bxin33 at gmail dot com
GCC build triplet: PIII + Gentoo Linux 2.6.11 + GCC 3.3.5
GCC host triplet: PIII + Gentoo Linux 2.6.11 + GCC 3.3.5
GCC target triplet: PIII + Gentoo Linux 2.6.11 + GCC 3.3.5
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26927