You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Original bug ID: 375 Reporter: administrator Status: closed Resolution: not a bug Priority: normal Severity: minor Category: ~DO NOT USE (was: OCaml general)
I can hardly believe that this has not been spotted before, checked the
listings and found nothing similar, so here it goes:
code:
module type EXPR =
sig
type expr = Const of float
| Sum of expr * expr
| Diff of expr * expr
| Prod of expr * expr
| Quot of expr * expr
| Get of float
val simpl : expr -> expr
end
-- note: Expr is not matched against the signature )
module Expr ( : EXPR *) =
struct
type expr = Const of float
| Sum of expr * expr
| Diff of expr * expr
| Prod of expr * expr
| Quot of expr * expr
| Get of float
let rec simpl e =
match e with
Const c -> Const c
| Sum (f1, f2) ->
let f1' = simpl f1
and f2' = simpl f2 in
begin
match f1', f2' with
Const c1, Const c2 -> Const (c1 +. c2)
| e1, e2 -> Sum (e1, e2)
end
| x -> x
end
caml's reply in an emacs shell:
Objective Caml version 3.01
#use "expr.ml";;
module type EXPR =
sig
type expr =
Const of float
| Sum of expr * expr
| Diff of expr * expr
| Prod of expr * expr
| Quot of expr * expr
| Get of float
val simpl : expr -> expr
end
module Expr :
sig
type expr =
Const of float
| Sum of expr * expr
| Diff of expr * expr
| Prod of expr * expr
| Quot of expr * expr
| Get of float
val simpl : expr -> expr
end
let one = Expr.Const 1.0 and two = Expr.Const 2.0 in Expr.simpl (Expr.Sum
(one, two));;
: Expr.expr = Expr.Const 3
let e = Expr.Sum (Expr.Const 1.0, Expr.Const 2.0) in Expr.simpl e;;
Process inferior-caml bus error
Whatever the cause of this (I also tried it from a non-emacs shell, with the
same behaviour) it shouldn't die horribly.
Thanks, Laszlo
The text was updated successfully, but these errors were encountered:
I couldn't reproduce your bug, even on Solaris 5.6/sparc.
Can you give more details?
Is there an old expr.cmi around, for instance, which might confuse the
toplevel?
I only use ocaml (compiled from source with -O3, no custom libraries),
so the .cmi file never gets generated, and the bug shows up even in a
freshly started interpreter. If I have a bit of time later on today I
rebuild ocaml with a lower level of optimisation and let you know if
that changes anything.
I've recompiled caml as it comes (no higher level of optimisation) and
-O2. In both cases the code included in the bug report evaluates as
expected. So this appears to be a gcc bug related to compiling caml
with -O3.
Over-optimization by the C compiler. Still, would be interesting to see where
it generated wrong code, because that could point to an undefined behavior in
the OCaml runtime system.
Original bug ID: 375
Reporter: administrator
Status: closed
Resolution: not a bug
Priority: normal
Severity: minor
Category: ~DO NOT USE (was: OCaml general)
Bug description
Full_Name: Laszlo Nemeth
Version: 3.01
OS: SunOS ropas 5.7 Generic sun4u sparc SUNW,Ultra-4
Submission from: apnc209.216.216.211.in-addr.arpa (211.216.216.38)
Hi,
I can hardly believe that this has not been spotted before, checked the
listings and found nothing similar, so here it goes:
code:
module type EXPR =
sig
type expr = Const of float
| Sum of expr * expr
| Diff of expr * expr
| Prod of expr * expr
| Quot of expr * expr
| Get of float
end
-- note: Expr is not matched against the signature )
module Expr ( : EXPR *) =
struct
type expr = Const of float
| Sum of expr * expr
| Diff of expr * expr
| Prod of expr * expr
| Quot of expr * expr
| Get of float
end
caml's reply in an emacs shell:
#use "expr.ml";;
module type EXPR =
sig
type expr =
Const of float
| Sum of expr * expr
| Diff of expr * expr
| Prod of expr * expr
| Quot of expr * expr
| Get of float
val simpl : expr -> expr
end
module Expr :
sig
type expr =
Const of float
| Sum of expr * expr
| Diff of expr * expr
| Prod of expr * expr
| Quot of expr * expr
| Get of float
val simpl : expr -> expr
end
let one = Expr.Const 1.0 and two = Expr.Const 2.0 in Expr.simpl (Expr.Sum
(one, two));;
let e = Expr.Sum (Expr.Const 1.0, Expr.Const 2.0) in Expr.simpl e;;
Process inferior-caml bus error
Whatever the cause of this (I also tried it from a non-emacs shell, with the
same behaviour) it shouldn't die horribly.
Thanks, Laszlo
The text was updated successfully, but these errors were encountered: