Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0001750OCaml-for CamlIDL use 00:362004-07-08 12:09
Assigned To 
PlatformOSOS Version
Product Version 
Target VersionFixed in Version 
Summary0001750: CamlIDL: signed chars break Ocaml typesystem
DescriptionHere is an example:

signed char get0x80()
quote(call,"_res = '\x80';");

it compiles to

external get0x80 : unit -> char
    = "camlidl_signed_char_get0x80"


value camlidl_signed_char_get0x80(value _unit)
  signed char _res;
  value _vres;

  /* begin user-supplied calling sequence */
_res = '\x80';
  /* end user-supplied calling sequence */
  _vres = Val_int(_res);
  return _vres;

but (int)((signed char)'\x80') == -1! There is no such char value in
Ocaml (its chars are unsigned) so we are obviously in trouble.

Even worse, many compilers (including GCC and MSVC) assume that char is
signed by default so writing "char get0x80() ..." we will have just the
same problems.

What I propose: traslate "char" IDL type to "unsigned char" C type (as MIDL
compiler does) and prohibit using "signed char" IDL type (or at least
generate a warning)

- Dmitry Bely

TagsNo tags attached.
Attached Files

- Relationships

-  Notes
administrator (administrator)
2004-07-08 12:09

Fixed conversion C -> ML for "char" and "signed char" to force unsigned
interpretation. 2004-07-08, XL

- Issue History
Date Modified Username Field Change
2005-11-18 10:13 administrator New Issue
2017-02-16 14:37 xleroy Category CamlIDL => for CamlIDL use [^]
2017-02-23 16:43 doligez Category for CamlIDL use [^] => -for CamlIDL use [^]

Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker