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

new definition of CAMLreturn produces warnings #4129

Closed
vicuna opened this issue Oct 4, 2006 · 3 comments
Closed

new definition of CAMLreturn produces warnings #4129

vicuna opened this issue Oct 4, 2006 · 3 comments
Assignees
Labels

Comments

@vicuna
Copy link

vicuna commented Oct 4, 2006

Original bug ID: 4129
Reporter: @oandrieu
Assigned to: @damiendoligez
Status: closed (set by @damiendoligez on 2006-11-17T15:40:22Z)
Resolution: fixed
Priority: normal
Severity: minor
Version: 3.09.3
Fixed in version: 3.09.4+dev / +rc
Category: ~DO NOT USE (was: OCaml general)

Bug description

The new definition of CAMLreturn in 3.09.3 (cf. bug #4068) assumes that the returned values is of type value. When CAMLreturn is used in a function that returns a pointer type, the C compiler emits an annoying warning:

,----
| warning: initialization makes integer from pointer without a cast
| warning: return makes pointer from integer without a cast
`----

@vicuna
Copy link
Author

vicuna commented Nov 15, 2006

Comment author: @damiendoligez

If anyone has ideas for dealing with this, I want to hear them.

@vicuna
Copy link
Author

vicuna commented Nov 16, 2006

Comment author: @oandrieu

  • gcc has a typeof construct http://gcc.gnu.org/onlinedocs/gcc-4.1.1/gcc/Typeof.html#Typeof , so we could define CAMLreturn as:
    ,----
    | #define CAMLreturn(result) do{
    | typeof (result) caml__temp_result = (result);
    | caml_local_roots = caml__frame;
    | return (caml__temp_result);
    | }while(0)
    `----
    But we need something that works for all compilers.

  • How about adding a type argument to the macro ?
    ,----
    | #define CAMLreturnT(T, result) do{
    | T caml__temp_result = (result);
    | caml_local_roots = caml__frame;
    | return (caml__temp_result);
    | }while(0)
    |
    | #define CAMLreturn(result) CAMLreturnT(value, result)
    `----

@vicuna
Copy link
Author

vicuna commented Nov 17, 2006

Comment author: @damiendoligez

I've implemented your second suggestion in 3.09 branch.

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

No branches or pull requests

2 participants