caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: skaller <skaller@ozemail.com.au>
To: Brian Hurt <bhurt@spnz.org>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] Int overflow in literals
Date: 07 Nov 2003 18:22:24 +1100	[thread overview]
Message-ID: <1068189744.6194.44.camel@pelican> (raw)
In-Reply-To: <Pine.LNX.4.44.0311021021130.27942-100000@localhost.localdomain>

On Mon, 2003-11-03 at 03:23, Brian Hurt wrote:
> On 3 Nov 2003, skaller wrote:
> 
> > On Fri, 2003-10-31 at 08:14, Oleg Trott wrote:
> > > On Thursday 30 October 2003 03:05 pm, Issac Trotts wrote:
> > 
> > > 
> > > Or, better yet, use Big_int:
> > 
> > Felix does that, and i'm very happy with the idea.
> > Constant folding is done in "infinite" precision.
> > The check for size, if done, would occur in the backend
> > code generator .. not the parser.
> > 
> 
> This is a bad idea.  I'd like the constant folding to be done in the word 
> length that the code will be executed in- this way, there is no difference 
> between code that is executed at run time and code that is executed at 
> compile time.
> 

The results will be the same, so its a good idea :-)

The Felix types 'int', 'long' etc have the same sizes
as the corresponding C types. But the semantics are
NOT the same. Bitwise operations are not permitted,
and the result is undefined on overflow.

The Felix type 'int32' on the other hand is required
to be two's complement 32 bit, and allows overflow
as in C. Bitwise operations are not allowed.

The type 'uint32' allows bitwise operations.

The constant folder respects these semantics.
Actually only int type is folded .. and if the
result would overflow at run time then the behaviour
of the program is undefined, and so the well defined
result of constant folding is correct, since it is
an element of the set 'undefined' of all possible results :-)



-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


  parent reply	other threads:[~2003-11-07  8:23 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-10-30 13:53 Marcin 'Qrczak' Kowalczyk
2003-10-30 17:37 ` Alex Baretta
2003-10-30 17:59   ` Frederic van der Plancke
2003-10-30 19:20     ` Oleg Trott
2003-10-30 19:40       ` Marcin 'Qrczak' Kowalczyk
2003-10-30 20:05 ` Issac Trotts
2003-10-30 21:14   ` Oleg Trott
2003-10-30 21:26     ` Kenneth Knowles
2003-10-31  0:18       ` Jacques Garrigue
2003-10-31  2:05         ` Kenneth Knowles
2003-11-02 15:05     ` skaller
2003-11-02 16:23       ` Brian Hurt
2003-11-02 16:39         ` Marcin 'Qrczak' Kowalczyk
2003-11-07  7:22         ` skaller [this message]
2003-10-30 21:36   ` Frederic van der Plancke
2003-10-30 23:27     ` Issac Trotts
2003-10-30 23:43     ` Oleg Trott
2003-10-31 16:42 ` Xavier Leroy
2003-10-31 17:39   ` Marcin 'Qrczak' Kowalczyk
2003-10-31 17:50   ` Oleg Trott
2003-11-02 15:23   ` skaller
2003-11-02 16:37     ` Marcin 'Qrczak' Kowalczyk

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=1068189744.6194.44.camel@pelican \
    --to=skaller@ozemail.com.au \
    --cc=bhurt@spnz.org \
    --cc=caml-list@inria.fr \
    /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).