Skip to content

Commit 022439c

Browse files
authored
flambda-backend: Fix padding bug for float32 static values (#2763)
* Fix padding bug for float32 static values * Add test case * semicolon * Add comment
1 parent b07cd52 commit 022439c

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
(* TEST
2+
runtime5;
3+
include stdlib_beta;
4+
ocamlopt_flags="-extension layouts_alpha -extension small_numbers";
5+
native;
6+
*)
7+
8+
(* From https://github.com/ocaml-flambda/flambda-backend/pull/2698
9+
although submitted as part of
10+
https://github.com/ocaml-flambda/flambda-backend/pull/2763
11+
*)
12+
13+
module Float32_u = Stdlib_beta.Float32_u
14+
15+
type t =
16+
| Mutable_str of { mutable x : string }
17+
| Float32 of float32#
18+
19+
let[@inline always] go x y =
20+
let f =
21+
match x with
22+
| Float32 f32 ->
23+
(fun[@inline never] () ->
24+
match y with
25+
| Mutable_str _ -> f32
26+
| Float32 _ -> assert false)
27+
| Mutable_str _ -> assert false
28+
in
29+
f ()
30+
31+
let () =
32+
let x = Float32 #4.s in
33+
let y = Mutable_str { x = "s" } in
34+
let _ = go x y in
35+
()

0 commit comments

Comments
 (0)