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: 7010 Reporter: bryantosaurus Assigned to:@mshinwell Status: closed (set by @xavierleroy on 2017-02-16T14:16:43Z) Resolution: fixed Priority: normal Severity: minor Version: 4.02.3 Fixed in version: 4.03.0+dev / +beta1 Category: configure and build/install Monitored by:@diml
Bug description
19:30:23 ~/3rd/ocaml> git format-patch trunk --stdout | cat
From 749045d74ec9617e651901fbfe98d135061ec7e5 Mon Sep 17 00:00:00 2001
From: bryant <bryant@defrag.in>
Date: Wed, 7 Oct 2015 19:18:13 +0200
Subject: [PATCH] fix undefined left shift of negative value.
---
byterun/caml/mlvalues.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/byterun/caml/mlvalues.h b/byterun/caml/mlvalues.h
index 3b94d01..025bee1 100644
--- a/byterun/caml/mlvalues.h
+++ b/byterun/caml/mlvalues.h
@@ -68,7 +68,7 @@ typedef uintnat mark_t;
/* Conversion macro names are always of the form "to_from". */
/* Example: Val_long as in "Val from long" or "Val of long". */
-#define Val_long(x) (((intnat)(x) << 1) + 1)
+#define Val_long(x) ((intnat) (((uintnat)(x) << 1)) + 1)
#define Long_val(x) ((x) >> 1)
#define Max_long (((intnat)1 << (8 * sizeof(value) - 2)) - 1)
#define Min_long (-((intnat)1 << (8 * sizeof(value) - 2)))
--
1.7.10.4
If E1 has a signed
type and nonnegative value, and E1 × 2 E2 is representable in the result type, then that is
the resulting value; otherwise, the behavior is undefined.
This patch also has the pleasant side effect of permitting build with clang.
Thanks,
Bryant
Steps to reproduce
compile ocaml with clang. ./configure -cc clang.
The text was updated successfully, but these errors were encountered:
I just built 4.02.3 using clang on a Mac (clang-700.0.72) and didn't get this error. Which version of clang are you using? Can you paste the command line of the failing compilation command, and the compiler output?
I suspect that the change introduced in trunk (as part of a move to a higher optimization level) to use the "-fwrapv" compiler option will fix this problem.
Original bug ID: 7010
Reporter: bryantosaurus
Assigned to: @mshinwell
Status: closed (set by @xavierleroy on 2017-02-16T14:16:43Z)
Resolution: fixed
Priority: normal
Severity: minor
Version: 4.02.3
Fixed in version: 4.03.0+dev / +beta1
Category: configure and build/install
Monitored by: @diml
Bug description
Left-shifting signed negative values is undefined behavior. From 6.5.7 of http://open-std.org/JTC1/SC22/WG14/www/docs/n1256.pdf :
This patch also has the pleasant side effect of permitting build with clang.
Thanks,
Bryant
Steps to reproduce
compile ocaml with clang.
./configure -cc clang
.The text was updated successfully, but these errors were encountered: