Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0004473OCamlOCaml generalpublic2008-01-05 02:432008-01-18 04:54
Reportersol 
Assigned To 
PrioritynormalSeveritycrashReproducibilityalways
StatusclosedResolutionfixed 
PlatformOSOS Version
Product Version3.10.1 
Target VersionFixed in Version3.10+dev 
Summary0004473: Segfault when accessing an element of an array of float throught a polymorphic method.
DescriptionExample:
<code>
class xyz =
object
method nth : 'a . int -> 'a array -> 'a = fun x a -> a.(x mod Array.length a)
end
</code>

Running this with an array of string, int or options... works fine. But an array of float causes a segfault.
Tested in versions: 3.09.3 on mac osx 10
and 3.10.0 on windows xp.

However the following works fine:
<code>
let nth : int -> 'a array -> 'a = fun x a -> a.(x mod Array.length a)
</code>

TagsNo tags attached.
Attached Files

- Relationships

-  Notes
(0004404)
xleroy (administrator)
2008-01-07 15:47

Confirmed in 3.10.1. The culprit is probably Typeopt.array_element_kind, which doesn't know about universally-quantified type variables.
(0004405)
sol (reporter)
2008-01-07 16:55

The following works as a workaround:
First create a function and assign it to a class method.

let nth : 'a array -> int -> 'a = fun a i -> a.(i mod Array.length a)

class c =
  object
    method nth : 'a . 'a array -> int -> 'a = nth
end
(0004416)
garrigue (manager)
2008-01-18 04:54

I commited the fix for Typeopt.array_element_kind in CVS.

- Issue History
Date Modified Username Field Change
2008-01-05 02:43 sol New Issue
2008-01-07 15:47 xleroy Note Added: 0004404
2008-01-07 15:47 xleroy Status new => confirmed
2008-01-07 15:47 xleroy Product Version 3.09.3 => 3.10.1
2008-01-07 16:55 sol Note Added: 0004405
2008-01-18 04:54 garrigue Status confirmed => closed
2008-01-18 04:54 garrigue Note Added: 0004416
2008-01-18 04:54 garrigue Resolution open => fixed
2008-01-18 04:54 garrigue Fixed in Version => 3.10+dev


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker