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

CamlIDL: signed chars break Ocaml typesystem #8202

Closed
vicuna opened this issue Jul 11, 2003 · 1 comment
Closed

CamlIDL: signed chars break Ocaml typesystem #8202

vicuna opened this issue Jul 11, 2003 · 1 comment

Comments

@vicuna
Copy link

vicuna commented Jul 11, 2003

Original bug ID: 1750
Reporter: administrator
Status: closed
Resolution: fixed
Priority: normal
Severity: minor
Category: -for CamlIDL use https://github.com/xavierleroy/camlidl/issues

Bug description

Here is an example:

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

it compiles to

external get0x80 : unit -> char
= "camlidl_signed_char_get0x80"

and

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
@vicuna
Copy link
Author

vicuna commented Jul 8, 2004

Comment author: administrator

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant