public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
From: mvishnu@calix.com
To: gcc-gnats@gcc.gnu.org
Subject: c++/3005: improper evaluation of mixed mode expressions involving long long
Date: Wed, 30 May 2001 10:46:00 -0000	[thread overview]
Message-ID: <20010530174334.17941.qmail@sourceware.cygnus.com> (raw)

>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:


                 reply	other threads:[~2001-05-30 10:46 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20010530174334.17941.qmail@sourceware.cygnus.com \
    --to=mvishnu@calix.com \
    --cc=gcc-gnats@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).