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

UInt64 bug, possibly due to C coercion rules after a constant fold #117

Open
BarryBo opened this issue Oct 18, 2018 · 0 comments
Open

UInt64 bug, possibly due to C coercion rules after a constant fold #117

BarryBo opened this issue Oct 18, 2018 · 0 comments
Assignees

Comments

@BarryBo
Copy link
Contributor

BarryBo commented Oct 18, 2018

This is non-blocking. I have a workaround.

In F* code, if I write U64.(0UL -^ 1UL), I expect the result to be 64-bit 0xff...ffUL.

But in the extracted C code, I see the expression is constant-folded to (uint64_t)-1U;

However, it looks like both gcc and MSVC extend this by first converting -1 to a uint32 (0xffffffff) then unsigned-extending to 64-bit, to get 0x00000000ffffffff.

The generated code from gcc is:
; load 0xffffffff into 32-bit eax, which is zero-extended by the hw to 0x00000000ffffffff
1a: b8 ff ff ff ff mov $0xffffffff,%eax
; pass the value onward
1f: 48 89 45 f8 mov %rax,-0x8(%rbp)

Attached is a test.fst that repros the problem. Its comment block has the kremlin and gcc command lines needed to repro.
test.txt

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