caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: hugo <hugo.heuzard@gmail.com>
To: Tao Stein <taostein@gmail.com>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] strange integer division result in ocamlopt ...
Date: Sat, 18 Apr 2015 19:20:27 -0400	[thread overview]
Message-ID: <CAEYcRDEZZsrU-A2h-JJYkrMWBzsJ6r5F96Za7JhkRZuot92y5Q@mail.gmail.com> (raw)
In-Reply-To: <CABs4TjKGAp=qUriLwsk_x=oLCb4owd-xrn5DVro5JducFzokUA@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1291 bytes --]

see http://caml.inria.fr/mantis/view.php?id=6749

On Sat, Apr 18, 2015 at 7:14 PM, Tao Stein <taostein@gmail.com> wrote:

>
> I'm getting a strange result using ocamlopt that seems to violate the
> basic axioms of integer division.
>
> Some context first:
> taostein@~/b2/f2: which ocamlopt
> /Users/taostein/.opam/4.02.1/bin/ocamlopt
> taostein@~/b2/f2: ocamlopt -o foo.opt foo.ml
> taostein@~/b2/f2: which ocamlc
> /Users/taostein/.opam/4.02.1/bin/ocamlc
> taostein@~/artcode/b2/f2: ocamlc -o foo foo.ml
>
> Built with ocamlopt, the following code throws an exception. Built with
> ocamlc it does not.
>
> let k1 = 1;;
> let rec f i k =
>   if (((i / k1) * k1 + (i mod k1)) <> i)
>   then (raise (Failure "violation of integer division axiom"))
>   else (if (i < 10) then (f (i + 1) k) else ()) in
> f 0 1;;
>
> Now, if I change the above only on line 3 changing k1 to k, then it works
> fine, no problem.
>
> let k1 = 1;;
> let rec f i k =
>   if (((i / k) * k + (i mod k)) <> i)
>   then (raise (Failure "violation of integer division axiom"))
>   else (if (i < 10) then (f (i + 1) k) else ()) in
> f 0 1;;
>
> No exception in either ocamlc or ocamlopt.
>
> Using ocamlopt, it seems 1 mod 1 = 1. This is problematic.
>
> Tao Stein / 石涛
>
>

[-- Attachment #2: Type: text/html, Size: 2024 bytes --]

      reply	other threads:[~2015-04-18 23:20 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-18 23:14 Tao Stein
2015-04-18 23:20 ` hugo [this message]

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=CAEYcRDEZZsrU-A2h-JJYkrMWBzsJ6r5F96Za7JhkRZuot92y5Q@mail.gmail.com \
    --to=hugo.heuzard@gmail.com \
    --cc=caml-list@inria.fr \
    --cc=taostein@gmail.com \
    /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).