Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0000224OCamlOCaml generalpublic2000-11-23 02:322000-11-26 20:28
Reporteradministrator 
Assigned To 
PrioritynormalSeverityminorReproducibilityalways
StatusclosedResolutionfixed 
PlatformOSOS Version
Product Version 
Target VersionFixed in Version 
Summary0000224: caml/alloc.h prototype for copy_string() should have "const" qualifier for argument
DescriptionFull_Name: Westley Weimer
Version: 3.0.0
OS: linux
Submission from: user-vcaumjr.dsl.mindspring.com (216.175.90.123)


The prototype for copy_string() in caml/alloc.h should (probably) read:
    value copy_string (const char *);
It currently reads:
     value copy_string (char *); /* not right! */
This prevents proper C/OCAML programs from compiling (without great
contortions)
if the compiler is paranoid about dropping type qualifiers (g++ is an example of

such a compiler: this actually bit me in real life, and in C++ it can be
illegal
to cast from "const char *" to "char *" so there is no easy fix). A stub
procedure
trying to copy a C "const char *" (that it got from a library, say) over to an
OCAML
value using the current copy_string() will be unable to because passing it to
copy_string nominally discards the "const" type qualifier. Since copy_string()
does
not (I presume!) actually modify its arguments, it should be declared "const".
This
should not break any current code but will allow more (correct) code to compile.
I
changed it on my local system and it didn't seem to break anything. You may also

want to do something similar for copy_string_array().

    - Wes

TagsNo tags attached.
Attached Files

- Relationships

-  Notes
(0000470)
administrator (administrator)
2000-11-26 20:28

> Full_Name: Westley Weimer
> The prototype for copy_string() in caml/alloc.h should (probably) read:
> value copy_string (const char *);

We'll try adding it, but const is generally a pain in the neck because
the contravariance of functions is not handled correctly, so we might
backtrack on this.

> such a compiler: this actually bit me in real life, and in C++ it can be
> illegal to cast from "const char *" to "char *" so there is no easy fix).

C++ trying to be type-safe ? Ha ha.

-- Damien

- Issue History
Date Modified Username Field Change
2005-11-18 10:13 administrator New Issue


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker