This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug math/20894] New: The strange behavior of the log function


https://sourceware.org/bugzilla/show_bug.cgi?id=20894

            Bug ID: 20894
           Summary: The strange behavior of the log function
           Product: glibc
           Version: 2.19
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: math
          Assignee: unassigned at sourceware dot org
          Reporter: l6979630 at hotmail dot com
  Target Milestone: ---

I found this bug on ubuntu 14.04 with glibc 2.19 and arch linux with glibc
2.24.


#include<cstdio>
#include<cmath>
using namespace std;
double p[5];
int ans;
double yy(int x){
        return log(x);
}
double cc(int x){
        return p[x];
}
int main(){
p[2]=log(2);
double a = log(2)/log(2);
printf("%d\n",(int)a);
printf("%d\n",(int)(log(2)/log(2)));
printf("%d\n",(int)(yy(2)/yy(2)));
printf("%d\n",(int)(cc(2)/cc(2)));
}


Just compile this program in "g++ -match=i686 -m32 code,cpp"
Then you will got outputs like:
1
0
0
1

It is really strange.......

-- 
You are receiving this mail because:
You are on the CC list for the bug.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]