This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
c++/3005: improper evaluation of mixed mode expressions involving long long
- To: gcc-gnats at gcc dot gnu dot org
- Subject: c++/3005: improper evaluation of mixed mode expressions involving long long
- From: mvishnu at calix dot com
- Date: 30 May 2001 17:43:34 -0000
- Reply-To: mvishnu at calix dot com
>Number: 3005
>Category: c++
>Synopsis: improper evaluation of mixed mode expressions involving long long
>Confidential: no
>Severity: serious
>Priority: high
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Wed May 30 10:46:01 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator: Meenan Vishnu
>Release: 2.95.3
>Organization:
>Environment:
/home/mvishnu/Simulation > g++ -v
Reading specs from /usr/local/lib/gcc-lib/sparc-sun-solaris2.7/2.95.3/specs
gcc version 2.95.3 20010315 (release)
/home/mvishnu/Simulation > uname -a
SunOS petuxa08 5.7 Generic_106541-12 sun4u sparc SUNW,Ultra-80
>Description:
#include <iostream>
int main()
{
double r;
int n = 38;
unsigned long long mi = 16960000;
r = n * 424 * 1000000 / mi;
cout << "r = " << r << endl;
unsigned long long t = n;
double r1;
r1 = t * 424 * 1000000 / mi;
cout << "r1 = " << r1 << endl;
}
>How-To-Repeat:
Compile the above (small) program using g++ (version 2.95.3) and run. The value of r should be 950. Instead,
it prints r = 1.08766e+12
>Fix:
A simple work around is also shown in the program. Use
a temporary variable t as shown in the computation of r1.
>Release-Note:
>Audit-Trail:
>Unformatted: