9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: erik quanstrom <quanstro@quanstro.net>
To: 9fans@9fans.net
Subject: Re: [9fans] compiler double bug.
Date: Tue,  1 Dec 2009 16:45:05 -0500	[thread overview]
Message-ID: <0ac7d411bce930a524248146c7150ada@ladd.quanstro.net> (raw)
In-Reply-To: <<0232aa110f8423b8381e009b6cda7cef@terzarima.net>>

On Tue Dec  1 16:32:33 EST 2009, forsyth@terzarima.net wrote:
> those fixes really don't seem right to me. the problem is in getival
> or its callers. somewhere along the way, ULONG_MAX is converted to double
> and then back to int (directly or indirectly). that yields a trap. now, in the case
> 	int x;
> 	x = (uint)d;
> the compiler is wrong to eliminate the cast, but then again, if x isn't uint
> that's not going to work properly anyway (since x will go negative for big enough values of d).

i don't claim this is the best way to do this!

but getival does elimate the traps.  try it.  it is okay to pass ULONG_MAX
bac as a uint return value, isn't it?  i don't see the compiler doing the
wrong thing in this case.  and ULONG_MAX is an okay uint
value.  (probablly should have used UINT.)

since there are always numbers (42158668170.) that will trap
even if using uint (or even vlong), i don't see how to avoid doing
the comparison in floating point.

- erik



       reply	other threads:[~2009-12-01 21:45 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <<0232aa110f8423b8381e009b6cda7cef@terzarima.net>
2009-12-01 21:45 ` erik quanstrom [this message]
     [not found] <<d5e75e65219a1207aad92a000119dba0@terzarima.net>
2009-12-02  1:59 ` erik quanstrom
     [not found] <<d893fc0b1d0b52a1dd610d7eb14279d3@terzarima.net>
2009-12-01 22:31 ` erik quanstrom
2009-12-01 23:33   ` Charles Forsyth
     [not found] <<dc10137c2661c11595d2aa2ca370ba45@brasstown.quanstro.net>
2009-12-01 18:53 ` erik quanstrom
     [not found] <<a4d2df97e4d97d460ae33ca0800a4060@terzarima.net>
2009-12-01 18:41 ` erik quanstrom
2009-12-01 21:35   ` Charles Forsyth
2009-12-01 22:19   ` Charles Forsyth
     [not found] <<615bb2c21f211025b5d9aba799fffe0d@terzarima.net>
2009-12-01 16:39 ` erik quanstrom
2009-12-01 17:02   ` Charles Forsyth
2009-12-01 16:39 ` erik quanstrom
     [not found] <<9987774388a28369b01fa5658da35af9@terzarima.net>
2009-12-01 15:05 ` erik quanstrom
2009-12-01 16:31   ` Charles Forsyth
     [not found] <<2d42b6b28807634253ba28dc55a96de6@brasstown.quanstro.net>
2009-12-01  8:02 ` erik quanstrom
2009-12-01  9:43   ` Charles Forsyth
2009-12-01  9:45     ` Charles Forsyth
2009-12-01  7:55 erik quanstrom

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=0ac7d411bce930a524248146c7150ada@ladd.quanstro.net \
    --to=quanstro@quanstro.net \
    --cc=9fans@9fans.net \
    /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 NNTP newsgroup(s).