Bug 201670

Summary: Result of conversion of double to long long differs in valgrind and non-valgrind runs
Product: [Developer tools] valgrind Reporter: rudolf.hornig
Component: generalAssignee: Julian Seward <jseward>
Status: RESOLVED DUPLICATE    
Severity: normal CC: njn, tom
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Ubuntu   
OS: Linux   
Latest Commit: Version Fixed In:

Description rudolf.hornig 2009-07-27 16:51:07 UTC
Version:           valgrind-3.4.1-Debian (using KDE 4.2.4)
Compiler:          gcc 4.3 
OS:                Linux
Installed from:    Ubuntu Packages

uname -a
Linux hal90000 2.6.28-13-generic #45-Ubuntu SMP Tue Jun 30 19:49:51 UTC 2009 i686 GNU/Linux

The output of the followinfg program differs it it is run under valgrind:

#include <stdio.h>

int main() {
  char *x = "\x19\x6d\xb2\x9a\xba\x7e\x15\x40";
  double d = *(double *)x;
  printf("\nlong long:%lld \n", (long long)(d*(1e12)));
}

The output without valgrind:
long long:5373758713855

using valgrind:
long long:5373758713856
Comment 1 Nicholas Nethercote 2009-07-28 00:24:12 UTC
This is probably a dup of bug 197915.  Rudolf, what do you think?
Comment 2 rudolf.hornig 2009-07-28 11:34:28 UTC
Confirmed. After some research, I have recompiled the code with -msse2 -mfpmath=sse options (forcing to use 64bit floats on an intel CPU). and the valgrind and non-valgind output is now the same. 

Sorry for the confusion. This is really a dauplicate.
Comment 3 Tom Hughes 2009-07-28 11:41:00 UTC

*** This bug has been marked as a duplicate of bug 197915 ***