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

Bug in clightgen: Int_addrof uses Int.repr instead of Ptrofs.repr #216

Closed
andrew-appel opened this issue Jan 14, 2018 · 1 comment
Closed

Comments

@andrew-appel
Copy link

Consider the following C code:

struct list {unsigned head; struct list *tail;};
struct list three[] = { {1, three+1}, {2, three+2}, {3, NULL} };

Clightgen produces:

Definition v_three := {|
gvar_info := (tarray (Tstruct _list noattr) 3);
gvar_init := (Init_int32 (Int.repr 1) :: Init_addrof _three (Int.repr 8) ::
Init_int32 (Int.repr 2) ::
Init_addrof _three (Int.repr 16) ::
Init_int32 (Int.repr 3) :: Init_int32 (Int.repr 0) :: nil);
gvar_readonly := false;
gvar_volatile := false
|}.

Coq says: The term "Int.repr 8" has type "int" while it is expected to have type "ptrofs".

Clightgen should produce:

Definition v_three := {|
gvar_info := (tarray (Tstruct _list noattr) 3);
gvar_init := (Init_int32 (Int.repr 1) :: Init_addrof _three (Ptrofs.repr 8) ::
Init_int32 (Int.repr 2) ::
Init_addrof _three (Ptrofs.repr 16) ::
Init_int32 (Int.repr 3) :: Init_int32 (Int.repr 0) :: nil);
gvar_readonly := false;
gvar_volatile := false
|}.

@xavierleroy
Copy link
Contributor

xavierleroy commented Jan 15, 2018

Thanks for the report. Fixed by @bschommer in commit ce7013f . Will be in release 3.2.

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

No branches or pull requests

2 participants