Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Weak.create should reject negative lengths #7795

vicuna opened this issue May 13, 2018 · 2 comments


Copy link

commented May 13, 2018

Original bug ID: 7795
Reporter: @kayceesrk
Status: resolved (set by @xavierleroy on 2018-05-21T16:44:32Z)
Resolution: fixed
Priority: normal
Severity: minor
Fixed in version: 4.08.0+dev/beta1/beta2
Category: standard library
Monitored by: @gasche

Bug description

Weak.create accepts -1 for the length. It should raise Invalid_argument for negative lengths. It appears that the bounds check in caml_weak_create is off by one.

Steps to reproduce

$ ocaml
OCaml version 4.08.0+dev0-2018-04-09

let v = Weak.create (-1);;

val v : '_weak1 Weak.t =

Weak.length v;;

  • : int = -1

This comment has been minimized.

Copy link

commented May 13, 2018

Comment author: @kayceesrk

I've opened #1782 which fixes this bug.


This comment has been minimized.

Copy link

commented May 21, 2018

Comment author: @xavierleroy

GPR was merged in trunk.

@vicuna vicuna closed this May 21, 2018

@vicuna vicuna added stdlib bug labels Mar 14, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
1 participant
You can’t perform that action at this time.