Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0007655OCamldocumentationpublic2017-10-09 15:372017-10-15 01:43
Reportermottl 
Assigned Togasche 
PrioritynormalSeveritytextReproducibilityhave not tried
StatusresolvedResolutionfixed 
PlatformOSOS Version
Product Version4.05.0 
Target VersionFixed in Version4.06.0 +dev/beta1/beta2/rc1 
Summary0007655: Unclear semantics of [@@noalloc]
DescriptionThe manual does not seem to specify the behavior of external function declarations with the [@@noalloc] attribute if both a byte and native code entry point are declared. Though one would typically expect both entry points to have the same allocation behavior, this is eminently not the case when the function also declares that it returns unboxed values.

E.g. many numeric functions in Pervasives return unboxed doubles, which have to be explicitly allocated for byte code but not for native code. The functions are nevertheless declared with [@@noalloc]. I guess the byte code interpreter always ignores this attribute, otherwise the current Pervasives implementation would not be safe.

I think the expected behavior of [@@noalloc] with byte and native code should be documented in the C-interface section of the manual.
TagsNo tags attached.
Attached Files

- Relationships

-  Notes
(0018523)
xleroy (administrator)
2017-10-09 20:17

Yes, [@@noalloc] and several other function attributes such as [@@unboxed] apply only in native code. Feel free to suggest a better wording for the reference manual to make this point clearer.
(0018526)
mottl (reporter)
2017-10-09 21:22

Indeed, I just realized that the main section has a small note that it only applies to the native code compiler. But in its subsections (about unboxing and direct C-calls respectively) the text only refers to "the OCaml compiler". The note at the beginning of the main section is easy to miss. I knew that unboxing / untagging would only work with the native code compiler, but I always mistakenly believed that "noalloc" applied to byte code stubs, too.

I have just submitted a pull request that hopefully improves the wording in subsections.
(0018567)
gasche (administrator)
2017-10-15 01:43

Fixed by merging Markus' pull request: https://github.com/ocaml/ocaml/pull/1422 [^]

- Issue History
Date Modified Username Field Change
2017-10-09 15:37 mottl New Issue
2017-10-09 20:17 xleroy Note Added: 0018523
2017-10-09 20:17 xleroy Severity minor => text
2017-10-09 20:17 xleroy Status new => acknowledged
2017-10-09 21:22 mottl Note Added: 0018526
2017-10-15 01:43 gasche Note Added: 0018567
2017-10-15 01:43 gasche Status acknowledged => resolved
2017-10-15 01:43 gasche Fixed in Version => 4.06.0 +dev/beta1/beta2/rc1
2017-10-15 01:43 gasche Resolution open => fixed
2017-10-15 01:43 gasche Assigned To => gasche


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker